小编Sco*_*son的帖子

Seaborn 散点图大小和抖动

我有以下散点图代码

dimens = (12, 10)
fig, ax = plt.subplots(figsize=dimens)
sns.scatterplot(data = information, x = 'latitude', y = 'longitude', hue="genre", s=200,
                x_jitter=4, y_jitter=4, ax=ax)
Run Code Online (Sandbox Code Playgroud)

无论我将抖动更改为什么,绘图仍然非常接近。它出什么问题了?

示例数据框:

 store      longitude       latitude      genre
mcdonalds    140.232323      40.434343     all
kfc          140.232323      40.434343     chicken
burgerking   138.434343      35.545433     burger
fiveguys     137.323984      36.543322     burger
Run Code Online (Sandbox Code Playgroud)

python seaborn jupyter-notebook

9
推荐指数
2
解决办法
1万
查看次数

导入 DataFrames - 没有这样的文件或目录

我正在尝试将 csv 文件作为数据框导入 Jupyter 笔记本中。

rest_relation = pd.read_csv('store_id_relation.csv', delimiter=',')
Run Code Online (Sandbox Code Playgroud)

但我收到这个错误

FileNotFoundError: [Errno 2] No such file or directory: 'store_id_relation.csv'
Run Code Online (Sandbox Code Playgroud)

store_id_relation.csv 肯定位于数据文件夹中,我尝试将 data\ 添加到文件位置,但出现相同的错误。这里出了什么问题?

在此输入图像描述

python jupyter-notebook

7
推荐指数
2
解决办法
2万
查看次数

删除数据帧中字符后的所有内容

如果我有以下数据框“国家”:

  country      info
 england       london-europe
 scotland      edinburgh-europe
 china         beijing-asia
 unitedstates  washington-north_america
Run Code Online (Sandbox Code Playgroud)

我想获取信息字段,并且必须删除“-”之后的所有内容,变为:

 country      info
 england       london
 scotland      edinburgh
 china         beijing
 unitedstates  washington
Run Code Online (Sandbox Code Playgroud)

我该怎么做呢?

python dataframe pandas

1
推荐指数
1
解决办法
48
查看次数

标签 统计

python ×3

jupyter-notebook ×2

dataframe ×1

pandas ×1

seaborn ×1