Python - 查找 Pandas DataFrame 统计摘要
要查找 DataFrame 的统计摘要,请使用 describe() 方法。首先,我们使用别名导入了以下 pandas 库
import pandas as pd
以下是我们的 CSV 文件,我们正在创建一个 Pandas DataFrame −
dataFrame = pd.read_csv("C:\Users\amit_\Desktop\CarRecords.csv")现在,获取我们 Pandas DataFrame 的统计摘要 −
dataFrame.describe()
示例
以下为完整代码
import pandas as pd
# reading csv file
dataFrame = pd.read_csv("C:\Users\amit_\Desktop\CarRecords.csv")
print("DataFrame...\n",dataFrame)
# count the rows and columns in a DataFrame
print("\nNumber of rows and column in our DataFrame = ",dataFrame.shape)
# summary of DataFrame
print("\nGet the summary of statistics of a DataFrame = \n",dataFrame.describe())
# returns top 7 row records
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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP