python 结合视频游戏名称,使 Dataframe 的销售[重复]

lf3rwulv  于 2023-04-04  发布在  Python
关注(0)|答案(1)|浏览(83)

此问题在此处已有答案

Turn off errorbars in Seaborn Bar Plot(3个答案)
十小时前关门了。
这篇文章是10小时前编辑并提交审查的。

**编辑:**理解为什么错误条出现,为什么我需要将其设置为12而不是10,有2个重复的名称为侠盗猎车手和使命召唤,有没有一种方法将这两个重复(基于这些游戏的控制台)结合到NA_Sales?

代码如下:

#Setting up enviornment
    import pandas as pd
    import matplotlib.pyplot as plt
    import seaborn as sns
    import numpy as np

    df = pd.read_csv('Video_Games.csv')

    %matplotlib inline
#Most sucessful games NA after 2010

    #Boolean Filtering for year
    filtered_df = df[df[('Year_of_Release')] > 2010]

    #Bar Chart creation
    sns.barplot(x='Name', 
                y='NA_Sales',
                data = filtered_df.nlargest(12, 'NA_Sales'))
    plt.xticks(rotation=90)
    plt.title('Most Successful Games in North America by Revenue')
    plt.xlabel('Game Title')
    plt.ylabel('Revenue (in the Millions)')
    plt.rc('xtick', labelsize=8)
    plt.grid(axis="y")

输出:

az31mfrm

az31mfrm1#

使用errorbar=None作为sns.barplot的参数来删除误差条:

sns.barplot(x='Name', 
            y='NA_Sales',
            data = filtered_df.nlargest(12, 'NA_Sales'),
            errorbar=None)

相关问题