在熊猫数据框上运行round-函数无效。
- 为什么会这样?
- 更通用的方法是什么?
import pandas as pd
df_round=pd.DataFrame({'index': {0: 0.0, 1: 2.563624, 2: 5.127248, 3: 0.0},
'time': {0: 10.254496, 1: 20.508992, 2: 15.381744, 3: 10.254496},
'ph_1': {0: 7.690872, 1: 12.81812, 2: 20.508992, 3: 7.690872},
'ph_2': {0: 17.945368, 1: 7.690872, 2: 20.508992, 3: 17.945368},
'text': {0: 'foo', 1: 'bar', 2: 'spa', 3: 'm'}})
print("Before\n")
print(df_round)
decimals = pd.Series([1, 0, 2], index=['time','ph_1','ph_2'])
df_round=df_round.round(decimals)
print("After\n")
print(df_round)
失败:控制台打印两次完全相同。
答案 0 :(得分:0)
对我来说,上一个熊猫版本[b'123.sql', b'abc.sql', b'xyz.sql']
运作良好,替代解决方案是使用0.23.4
:
dictionary