Seaborn load_dataset [英] Seaborn load_dataset
问题描述
我正在尝试按照示例 <
我可以使上面的示例起作用,但是该行:
I can get the above example working, however the line:
tips = sns.load_dataset("tips")
完全没有解释。我已经找到了tips.csv文件,但是似乎找不到关于load_dataset具体作用的足够文档。我试图创建自己的csv并加载它,但无济于事。我还重命名了Tips文件,它仍然可以工作...
is not explained at all. I have located the tips.csv file, but I can't seem to find adequate documentation on what load_dataset specifically does. I tried to create my own csv and load this, but to no avail. I also renamed the tips file and it still worked...
我的问题是:
在哪里 load_dataset
实际在查找文件吗?我可以实际将其用于自己的箱形图吗?
Where is load_dataset
actually looking for files? Can I actually use this for my own boxplots?
编辑:我设法使用自己的 DataFrame
来使自己的箱形图工作,但是我仍然想知道是否 load_dataset
除了神秘的教程示例外,还用于其他任何用途。
I managed to get my own boxplots working using my own DataFrame
, but I am still wondering whether load_dataset
is used for anything more than mysterious tutorial examples.
推荐答案
load_dataset
在 https://github.com上查找在线csv文件/ mwaskom / seaborn-data 。这是文档字符串:
load_dataset
looks for online csv files on https://github.com/mwaskom/seaborn-data. Here's the docstring:
从在线存储库加载数据集(需要Internet)。
Load a dataset from the online repository (requires internet).
参数
name:str
数据集名称( name .csv https://github.com/mwaskom/seaborn-数据)。您可以使用:func:
get_dataset_names
name : str
Name of the dataset (name
.csv on
https://github.com/mwaskom/seaborn-data). You can obtain list of
available datasets using :func:get_dataset_names
kws获取
个可用数据集的列表:dict,可选
传递给pandas.read_csv
kws : dict, optional Passed to pandas.read_csv
如果要修改该在线数据集或引入自己的数据,则可能需要使用熊猫。 load_dataset
实际上返回一个熊猫 DataFrame
对象,您可以使用 type(tips)进行确认
。
If you want to modify that online dataset or bring in your own data, you likely have to use pandas. load_dataset
actually returns a pandas DataFrame
object, which you can confirm with type(tips)
.
如果您已经在名为tip2.csv的csv文件中创建了自己的数据,并将其保存在与脚本,使用它(在安装熊猫之后)将其加载到:
If you already created your own data in a csv file called, say, tips2.csv, and saved it in the same location as your script, use this (after installing pandas) to load it in:
import pandas as pd
tips2 = pd.read_csv('tips2.csv')
这篇关于Seaborn load_dataset的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!