第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

ValueError 形狀不匹配:對(duì)象無(wú)法廣播到單個(gè)形狀

ValueError 形狀不匹配:對(duì)象無(wú)法廣播到單個(gè)形狀

慕仙森 2023-07-05 18:03:00
這是我計(jì)劃用于創(chuàng)建條形圖的代碼。忽略下一行。我編寫(xiě)此代碼只是為了平衡代碼和細(xì)節(jié)。import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdef bar1():    df=pd.read_csv('C:\\Users\Bhuwan Bhatt\Desktop\IP PROJECT\Book1.csv',encoding= 'unicode_escape')    x=np.arange(11)    Countries=df['Country']    STotalMed=df['SummerTotal']    WTotalMed=df['WinterTotal']    plt.bar(x-0.25,STotalMed,width=.2, label='Total Medals by Countries in Summer',color='g')    plt.bar(x+0.25,WTotalMed,width=.2, label='Total Medals by Countries in Winter',color='r')    plt.xticks(np.arange(11),Countries,rotation=30)    plt.title('Olympics Data Analysis of Top 10 Countries',color='red',fontsize=10)    plt.xlabel('Countries')    plt.ylabel('Total Medals')    plt.grid()    plt.legend()    plt.show()bar1()由于某種原因我收到此錯(cuò)誤:Traceback (most recent call last):  File "C:/Users/Bhuwan Bhatt/Desktop/dsd.py", line 19, in <module>    bar1()  File "C:/Users/Bhuwan Bhatt/Desktop/dsd.py", line 10, in bar1    plt.bar(x-0.25,STotalMed,width=.2, label='Total Medals by Countries in Summer',color='g')  File "C:\Users\Bhuwan Bhatt\AppData\Local\Programs\Python\Python38-32\lib\site-packages\matplotlib\pyplot.py", line 2471, in bar    return gca().bar(  File "C:\Users\Bhuwan Bhatt\AppData\Local\Programs\Python\Python38-32\lib\site-packages\matplotlib\__init__.py", line 1438, in inner    return func(ax, *map(sanitize_sequence, args), **kwargs)INFO-----> SummerTimesPart : 各個(gè)國(guó)家在夏季參加的次數(shù) WinterTimesPart : 各個(gè)國(guó)家在冬季參加的次數(shù)
查看完整描述

1 回答

?
森林海

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊

只是改變

x=np.arange(11)

to 

x = np.arange(len(df))

plt.xticks(np.arange(11),Countries,rotation=30) 

to

plt.xticks(x,Countries,rotation=30)


查看完整回答
反對(duì) 回復(fù) 2023-07-05
  • 1 回答
  • 0 關(guān)注
  • 137 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)