python - 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
我不明白为什么列价格的类型之间存在这种类型的不一致。
有什么建议么?
解决方案
的返回值Series.describe()
是具有描述性统计信息的系列。dtype
您在系列中看到的不是原始dtype
列的,而是统计dtype
信息的 - 即float
. 结果name
是price
因为那被设置为 Series 的名称autos["price"]
。
推荐阅读
- java - 如何获取子窗口的所有标题?
- php - 从 MySQL 获取价值,并将它们放入其他表中(一次多个值)
- python-3.x - 获取与 IP 关联的所有主机名
- statistics - 什么是一致性指数(c-index)?
- reactjs - 使用 react-snapshot 构建静态反应页面时缺少 DOM
- java - 将 Guava 23.0 导入 Eclipse Photon 4.8.0
- php - 无法将 PDF 文档加载到我的数据库 php 中的 blob 类型
- docker - docker phpmyadmin 和 nginx 无法通过 phpmyadmin mysqli_real_connect() 登录到 db
- python - 如何使用 Python 将网页下载为 PDF?
- angular - 每次输入时将特定的 ion-tab 重置为主视图