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值。为什么会发生这种情况,这会影响我的分析吗?
您的熊猫设置可能设置为以科学计数法显示大量数字。您可以使用pd.set_option('display.float_format', lambda x: '%.3f' % x)