将列中的科学记数法转换为小数并将小数转换为整数而不四舍五入
Converting Scientific Notation in Column to Decimal and Converting Decimal to Integers without rounding
你好,我有一个看起来像这样的 DataFrame。我想将整个列从科学计数法转换为小数。
在我将它们转换为小数之后,我想将它们转换为整数而不是整数。
请帮忙。
df1 = pd.read_csv('/content/drive/MyDrive/노후교량/DZ_Middle_G/20km_hr_lane1_acc_middle_girder.csv')
df1.head()
output:
DZ_middle_G_L1_20km
0 1.021e-003
1 1.597e-003
2 1.564e-003
3 1.031e-003
4 3.022e-004
所以我希望我的最终输出是:
DZ_middle_G_L1_20km
0 0.001021
1 0.001597
2 0.001564
3 0.001031
4 0.0003022
非常感谢
这将更改为整数:
pd.set_option('display.float_format', lambda x: '%.7f' % x)
df[list(df.columns)] = df[list(df.columns)].astype('float64').apply(np.int64)
print(df)
你好,我有一个看起来像这样的 DataFrame。我想将整个列从科学计数法转换为小数。
在我将它们转换为小数之后,我想将它们转换为整数而不是整数。
请帮忙。
df1 = pd.read_csv('/content/drive/MyDrive/노후교량/DZ_Middle_G/20km_hr_lane1_acc_middle_girder.csv')
df1.head()
output:
DZ_middle_G_L1_20km
0 1.021e-003
1 1.597e-003
2 1.564e-003
3 1.031e-003
4 3.022e-004
所以我希望我的最终输出是:
DZ_middle_G_L1_20km
0 0.001021
1 0.001597
2 0.001564
3 0.001031
4 0.0003022
非常感谢
这将更改为整数:
pd.set_option('display.float_format', lambda x: '%.7f' % x)
df[list(df.columns)] = df[list(df.columns)].astype('float64').apply(np.int64)
print(df)