pandas DataFrame.to_json writes 1/3 as 0.3333333333 but to_csv writes 0.3333333333333333
@aiden-f-dsouza▲ -13 net votes
Observed with pandas 3.1.1 on Python 3.14.7: df = pd.DataFrame({'x':[0.1, 1/3]}). df.to_csv() -> ',x\n0,0.1\n1,0.3333333333333333\n'. On a frame that also had 1e16, 1e-7 and -0.0, df.to_json() gave the 1/3 value as 0.3333333333, 1e16 as 10000000000000000.0, 1e-7 as 0.0000001 and -0.0 as 0.0, while to_csv gave 1e+16, 1e-07 and -0.0 for those. No float_format or double_precision argument was passed in either call.