如何使用描述、列和形状来解决这个问题?

问题描述 投票:0回答:1

给定数据帧“df”,使用以下命令并分析结果。 描述() 列 形状

import numpy as np
import pandas as pd
df = pd.read_csv('https://query.data.world/s/vBDCsoHCytUSLKkLvq851k2b8JOCkF', sep = '|',header = None)
print(df.describe())
print(df.columns)
print(df.shape)

此代码会导致以下错误:

File "C:\...\example_forest.py", line 10, in <module>
    df = pd.read_csv('https://query.data.world/s/vBDCsoHCytUSLKkLvq851k2b8JOCkF', sep = '|',header = None)
... more lines of traceback ...
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>```
pandas csv
1个回答
0
投票

导入ssl并像这样使用它。

import pandas as pd
import numpy as np
import ssl # this is the import you need

# this is a way to use the module it is included in the python installation.
ssl._create_default_https_context = ssl._create_unverified_context

df = pd.read_csv('https://query.data.world/s/vBDCsoHCytUSLKkLvq851k2b8JOCkF', sep = ',')

print(df.describe())
print(df.columns)
print(df.shape)

您不需要 pip 安装此模块。

© www.soinside.com 2019 - 2024. All rights reserved.