Python - 查找 Pandas DataFrame 的统计信息摘要
要查找DataFrame的统计信息摘要,请使用describe()方法。首先,我们导入了以下带有别名的pandas库
import pandas as pd
以下是我们的CSV文件,我们正在创建一个PandasDataFrame-
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\CarRecords.csv")现在,获取我们的PandasDataFrame的统计摘要-
dataFrame.describe()
示例
以下是完整代码
import pandas as pd
#读取csv文件
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\CarRecords.csv")
print("DataFrame...\n",dataFrame)
#计算DataFrame中的行和列
print("\nNumber of rows and column in our DataFrame = ",dataFrame.shape)
#数据框摘要
print("\nGet the summary of statistics of a DataFrame = \n",dataFrame.describe())
#返回前7行记录
print("\nDataFrame with specific number of rows...\n",dataFrame.head(7))输出结果这将产生以下输出
DataFrame...
Car Place UnitsSold
0 Audi Bangalore 80
1 Porsche Mumbai 110
2 RollsRoyce Pune 100
3 BMW Delhi 95
4 Mercedes Hyderabad 80
5 Lamborghini Chandigarh 80
6 Audi Mumbai 100
7 Mercedes Pune 120
8 Lamborghini Delhi 100
Number of rows and colums in our DataFrame = (9, 3)
Get the summarry of statistics of a DataFrame =
UnitsSold
count 9.000000
mean 96.111111
std 14.092945
min 80.000000
25% 80.000000
50% 100.000000
75% 100.000000
max 120.000000
DataFrame with specific number of rows ...
Car Place UnitsSold
0 Audi Bangalore 80
1 Porsche Mumbai 110
2 RollsRoyce Pune 100
3 BMW Delhi 95
4 Mercedes Hyderabad 80
5 Lamborghini Chandigarh 80
6 Audi Mumbai 100热门推荐
10 中秋祝福语送朋友简短
11 新婚贺词简短的祝福语
12 节日祝福语幽默简短的
13 捐款人留言祝福语简短
14 女朋友考试祝福语简短
15 开店大吉文案祝福语简短
16 生日祝福语简短独特的
17 关于好的祝福语简短
18 宝子生日祝福语简短