“load_dataset”如何工作,因为它没有检测示例文件?

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

我正在了解 Datacamp 中的 seaborn 包,文档中包含的文件之一是“tips.csv”,它属于存储库 [https://github.com/mwaskom/seaborn-data][1 ] 我在其他帖子中找到了。

我正在尝试在 VSCode 上加载数据集“tips.csv”,但它会引发以下错误:

ValueError: 'tips.csv' is not one of the example datasets.```


  [1]: https://github.com/mwaskom/seaborn-data

> How can I solve this, as it is available in the link provided? I think
> it is not detecting the website, but I have internet connection.

python pandas csv github seaborn
1个回答
1
投票

我想您对文档感到困惑:

参数

name
str:
数据集名称(
{name}.csv
,位于 https://github.com/mwaskom/seaborn-data)。

dataset_names
实际上没有后缀。所以,你应该写
tips
而不是
tips.csv
:

print(sns.get_dataset_names())

[
    'anagrams',
    'anscombe',
    'attention',
    ...
    'taxis',
    'tips', # <-- here is yours
    'titanic'
]

df = sns.load_dataset("tips")

输出:

print(df)

     total_bill  tip     sex smoker   day    time  size
0         16.99 1.01  Female     No   Sun  Dinner     2
1         10.34 1.66    Male     No   Sun  Dinner     3
2         21.01 3.50    Male     No   Sun  Dinner     3
3         23.68 3.31    Male     No   Sun  Dinner     2
..          ...  ...     ...    ...   ...     ...   ...
240       27.18 2.00  Female    Yes   Sat  Dinner     2
241       22.67 2.00    Male    Yes   Sat  Dinner     2
242       17.82 1.75    Male     No   Sat  Dinner     2
243       18.78 3.00  Female     No  Thur  Dinner     2

[244 rows x 7 columns]
© www.soinside.com 2019 - 2024. All rights reserved.