import pandas as pd
def add_leading_zero_to_csv(path_to_csv_file):
# open the file
df_csv = pd.read_csv(path_to_csv_file)
# you can possibly specify the format of a column if needed
df_csv['specific_column'] = df_csv['specific_column'].map(lambda x: '%.2f' % x)
# save the file (with a precision of 3 for all the floats)
df_csv.to_csv(path_to_csv_file, index=False, float_format='%.3g')
在SPSS中直接实现似乎很困难。 一个可能的答案是:使用python+pandas。你知道吗
有关“g”格式的详细信息:Format Specification Mini-Language。你知道吗
注意浮点问题(例如,参见answer to this question)
相关问题 更多 >
编程相关推荐