首页 > 解决方案 > DataFrame.info() 与 DataFrame.Series.describe() 不同

问题描述

我在使用 Pandas 时遇到问题。

当我执行autos.info()它返回:

RangeIndex: 371528 entries, 0 to 371527
Data columns (total 20 columns):
 #   Column               Non-Null Count   Dtype 
---  ------               --------------   ----- 
 0   dateCrawled          371528 non-null  object
 1   name                 371528 non-null  object
 2   seller               371528 non-null  object
 3   offerType            371528 non-null  object
 4   price                371528 non-null  int64 
 5   abtest               371528 non-null  object
 6   vehicleType          333659 non-null  object
 7   yearOfRegistration   371528 non-null  int64 
 8   gearbox              351319 non-null  object
 9   powerPS              371528 non-null  int64 
 10  model                351044 non-null  object
 11  kilometer            371528 non-null  int64 
 12  monthOfRegistration  371528 non-null  int64 
 13  fuelType             338142 non-null  object
 14  brand                371528 non-null  object
 15  notRepairedDamage    299468 non-null  object
 16  dateCreated          371528 non-null  object
 17  nrOfPictures         371528 non-null  int64 
 18  postalCode           371528 non-null  int64 
 19  lastSeen             371528 non-null  object
dtypes: int64(7), object(13)
memory usage: 56.7+ MB

但是当我执行autos["price"].describe()它返回:

count    3.715280e+05
mean     1.729514e+04
std      3.587954e+06
min      0.000000e+00
25%      1.150000e+03
50%      2.950000e+03
75%      7.200000e+03
max      2.147484e+09
Name: price, dtype: float64

我不明白为什么列价格的类型之间存在这种类型的不一致。

有什么建议么?

标签: pythonpandasdata-science

解决方案


的返回值Series.describe()是具有描述性统计信息的系列。dtype您在系列中看到的不是原始dtype列的,而是统计dtype信息的 - 即float. 结果nameprice因为那被设置为 Series 的名称autos["price"]


推荐阅读