← 返回题库
初级

Weekly数据集探索性分析

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
import pandas as pd
weekly = pd.read_csv('https://liangdaima.com/static/data/statistics/Weekly.csv')
print(weekly.describe())
print('相关矩阵:')
numeric_cols = weekly.select_dtypes(include=['float64', 'int64']).columns
print(weekly[numeric_cols].corr())

示例

输入
solve()
期望输出
Year         Lag1  ...       Volume        Today
count  1089.000000  1089.000000  ...  1089.000000  1089.000000
mean   2000.048669     0.150585  ...     1.574618     0.149899
std       6.033182     2.357013  ...     1.686636     2.356927
min    1990.000000   -18.195000  ...     0.087465   -18.195000
25%    1995.000000    -1.154000  ...     0.332022    -1.154000
50%    2000.000000     0.241000  ...     1.002680     0.241000
75%    2005.000000     1.405000  ...     2.053727     1.405000
max    2010.000000    12.026000  ...     9.328214    12.026000

[8 rows x 8 columns]
相关矩阵:
            Year      Lag1      Lag2  ...      Lag5    Volume     Today
Year    1.000000 -0.032289 -0.033390  ... -0.030519  0.841942 -0.032460
Lag1   -0.032289  1.000000 -0.074853  ... -0.008183 -0.064951 -0.075032
Lag2   -0.033390 -0.074853  1.000000  ... -0.072499 -0.085513  0.059167
Lag3   -0.030006  0.058636 -0.075721  ...  0.060657 -0.069288 -0.071244
Lag4   -0.031128 -0.071274  0.058382  ... -0.075675 -0.061075 -0.007826
Lag5   -0.030519 -0.008183 -0.072499  ...  1.000000 -0.058517  0.011013
Volume  0.841942 -0.064951 -0.085513  ... -0.058517  1.000000 -0.033078
Today  -0.032460 -0.075032  0.059167  ...  0.011013 -0.033078  1.000000

[8 rows x 8 columns]
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码