这个没成功:
df.round({'A': 1})
df.round({'C': 2})
保留3位小数:
df['A']=df['A'].round(decimals=4)
延伸知识,pandas修改列:
blur是表头的一列:
import pandas as pd
import numpy as np
import os
list_path=r'C:\\check'
g = os.walk(list_path)
csv_files = ['%s/%s' % (i[0], j) for i in g for j in i[-1] if
j.endswith('csv')]
for label_file in csv_files:
df_label = pd.read_csv(label_file)
df_label.loc[df_label.blur>=2,'blur'] = 1
df_label.to_csv(label_file, index=False)
</