为什么我的价格列以电子倍数显示?

问题描述 投票:0回答:1

我使用此方法清除了“£”和“,”数据的货币列。还将非str值转换为NaN。

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

### Reading the excel file with dtype
df = pd.read_excel("Housing Market B16+5Miles.xlsx", dtype={"Price" : str})
df.loc[df['Price'] == 'POA','Price'] = np.nan

House_Price = df["Price"].str.replace(",","").str.replace("£","").astype("float")

del df['Price']

df["Price"] = House_Price
df

df.describe()

通过描述数据框,“价格”的列全为小数,末尾为e值。为什么会发生这种情况,这会影响我的分析吗?

pandas dataframe
1个回答
0
投票

您的熊猫设置可能设置为以科学计数法显示大量数字。您可以使用pd.set_option('display.float_format', lambda x: '%.3f' % x)

进行更改
© www.soinside.com 2019 - 2024. All rights reserved.