小编jak*_*kko的帖子

Seaborn多个barplots

我有一个像这样的pandas数据框:

    class       men       woman   children
0   first   0.91468    0.667971   0.660562
1   second  0.30012    0.329380   0.882608
2   third   0.11899    0.189747   0.121259
Run Code Online (Sandbox Code Playgroud)

如何使用看起来像这样的seaborn创建一个情节?我是否必须以某种方式重新安排我的数据?

python matplotlib pandas seaborn

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

将PySpark RDD添加为pyspark.sql.dataframe的新列

我有一个pyspark.sql.dataframe,其中每一行都是一篇新闻文章.然后我有一个RDD代表每篇文章中包含的单词.我想将单词的RDD添加为名为"words"的列到我的新文章的数据框中.我试过了

df.withColumn('words', words_rdd )
Run Code Online (Sandbox Code Playgroud)

但我得到了错误

AssertionError: col should be Column
Run Code Online (Sandbox Code Playgroud)

DataFrame看起来像这样

Articles
the cat and dog ran
we went to the park
today it will rain
Run Code Online (Sandbox Code Playgroud)

但我有3k新闻文章.

我应用了一个函数来清理文本,例如删除停用词,我有一个如下所示的RDD:

[[cat, dog, ran],[we, went, park],[today, will, rain]]
Run Code Online (Sandbox Code Playgroud)

我试图让我的Dataframe看起来像这样:

Articles                 Words
the cat and dog ran      [cat, dog, ran]
we went to the park      [we, went, park]
today it will rain       [today, will, rain]
Run Code Online (Sandbox Code Playgroud)

python apache-spark pyspark

4
推荐指数
2
解决办法
4770
查看次数

根据另一列的平均值填充列的值

我有一个pandas DataFrame.我试图根据Section栏中相应级别的平均价格填写价格列的nans.这样做有效而优雅的方法是什么?我的数据看起来像这样

Name   Sex  Section  Price
Joe     M      1       2
Bob     M      1       nan
Nancy   F      2       5
Grace   F      1       6
Jen     F      2       3
Paul    M      2       nan
Run Code Online (Sandbox Code Playgroud)

python pandas

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

标签 统计

python ×3

pandas ×2

apache-spark ×1

matplotlib ×1

pyspark ×1

seaborn ×1