确保在第二次调用 .describe() 时正确排除了 object 类型变量

Make sure you correctly excluded object type variables in your second call of .describe()

我在datacamp做一个题目如下:

Exploring Your Data Now you'll perform some data exploration using the Python pandas module. To get a sense of the data, you'll output statistics such as mean, median, count, and percentiles. The DataFrame recent_grads is still in your workspace

标题希望的目标如下:

Print the .dtypes of your data so that you know what each column contains.
Output basic summary statistics using a single pandas function.
With the same function from before, summary statistics for all columns that aren't of type object.

我的代码如下

# Print .dtypes
print(recent_grads.dtypes)
# Output summary statistics
print(recent_grads.describe())
# Exclude data of type object
print(recent_grads.describe(exclude='object'))

但是出现的错误信息如下

Make sure you correctly excluded object type variables in your second call of .describe()

请问link哪一部分不对,麻烦求助,谢谢!

describe() 方法的参数 exclude 需要一个 类似列表的 dtypes

请查看文档: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.describe.html

因此,在您的情况下,正确的调用是 recent_grads.describe(exclude=['object'])