【问题标题】:Graphing with Pandas Data Frame with various columns使用带有各种列的 Pandas 数据框进行绘图
【发布时间】:2021-08-11 03:43:54
【问题描述】:

我目前在数据框中有以下信息。

我需要创建一个图表,将预算与 5 部电影的全球总票房进行比较,其中 5 部电影具有最高的 'porcentage de ganancia'(或收入)。 似乎没有任何效果。

更新:

datos.nlargest(5, ['Porcentaje de ganancia'])

                                 Movie    Budget  ...  Year  Porcentaje de ganancia
19          E.T. the Extra-Terrestrial  10500000  ...  1982             7551.529086
69  Star Wars: Episode IV - A New Hope  11000000  ...  1977             7049.072791
97                      Wolf Warrior 2  30100000  ...  2017             2891.446641
83                       The Lion King  45000000  ...  1994             2408.268616
45                               Joker  55000000  ...  2019             1953.184202

非常感谢任何帮助!

【问题讨论】:

    标签: python pandas database dataframe csv


    【解决方案1】:

    首先,您需要获取porcentage de ganancia 列的n_largest 值。

    top_5 = df.nlargest(n=5, columns='porcentage de ganancia')
    

    然后,使用seaborn 进行绘图。阅读更多here 以了解如何自定义情节。

    import seaborn as sns
    
    g = sns.scatterplot(data=top_5, x='Budget', y='Worldwide Gross', hue='Movie')
    

    【讨论】:

      猜你喜欢
      • 2020-03-28
      • 2023-03-25
      • 2017-08-02
      • 1970-01-01
      • 2019-11-05
      • 2014-03-28
      • 1970-01-01
      • 2021-08-21
      • 2021-01-26
      相关资源
      最近更新 更多