import pandas as pd #import pandas package
# for visualisation fo the float data once we read the float data:
pd.set_option('display.html.table_schema', True) # to can see the dataframe/table as a html
pd.set_option('display.precision', 5) # setting up the precision point so can see the data how looks, here is 5
df = pd.DataFrame(np.random.randn(20,4)* 10 ** -12) # create random dataframe
Options and Settings
For visualization of the dataframe pandas.set_option
数据输出:
数据帧:
现在使用float格式='%.15f'参数
将写入文件输出:
现在使用float格式='%f'参数
将写入csvFor more details check pandas.DataFrame.to_csv
如果要将这些值用作列表中的格式化字符串,例如用作csvfile csv.writer的一部分,则可以在创建列表之前格式化这些数字:
使用
float_format
参数:其工作原理与csv类似:
相关问题 更多 >
编程相关推荐