Output different precision by column with pandas.DataFrame.to_csv()?

后端 未结 6 1709
深忆病人
深忆病人 2020-12-13 02:51

Question

Is it possible to specify a float precision specifically for each column to be printed by the Python pandas package method pandas.DataFrame.t

6条回答
  •  余生分开走
    2020-12-13 03:20

    The more current version of hknust's first line would be:

    df_data['vals'] = df_data['vals'].map(lambda x: '{0:.1}'.format(x))
    

    To print without scientific notation:

    df_data['vals'] = df_data['vals'].map(lambda x: '{0:.1f}'.format(x)) 
    

提交回复
热议问题