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

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

來自兩個(gè)變量列的Matplotlib條形圖-熊貓數(shù)據(jù)操作(主要是)

來自兩個(gè)變量列的Matplotlib條形圖-熊貓數(shù)據(jù)操作(主要是)

一只萌萌小番薯 2021-05-08 22:40:59
我有一個(gè)時(shí)間索引表,該表的BLIP列只有兩個(gè)值“ XX”和“ YY”。目的是顯示x軸以下的計(jì)數(shù)“ XX”和“ YY”,其中“ YY”。我正在嘗試使用Wes McKenney關(guān)于數(shù)據(jù)分析的書(我認(rèn)為是第26頁(yè))中的代碼從熊貓表中創(chuàng)建正確的數(shù)據(jù)結(jié)構(gòu):df = base_df.drop(columns=dropcols).set_index('Created')group = ['f2','BLIP']df0 = df_minus.groupby(group)agg_counts = df0.size().unstack().fillna(0)indexer = agg_counts.sum(1).argsort()count_subset = agg_counts.take(indexer).copy()table = count_subset.groupby('BLIP').resample('MS').count().unstack('BLIP')['BLIP']chart = table.plot.bar(title = chart_title, x=None, color = ['green', 'red', 'grey']);線agg_counts = df0.size().unstack().fillna(0) 導(dǎo)致以下錯(cuò)誤:TypeError: 'numpy.int32' object is not callable我在這里找到了一段代碼的寶石,但是找不到解密它的文檔。data['values'].plot(kind='bar', color=data.positive.map({True: 'g', False: 'r'}))這似乎是非常簡(jiǎn)單的,但是我對(duì)此頗為關(guān)注。大熊貓表格式類似于create_date f1 f2 f3 BLIP f5...dt_stamp    X  Y  Z  XX   K1dt_stamp    S  R  Y  YY   K3dt_stamp    P  P  T  XX   K1等等。我嘗試過杰西的建議df_plus =df[df['BLIP']=='XX']df_minus=df[df['BLIP']=='YY']ax = plt.axes()ax.bar(df_plus.index, df_plus['BLIP'], width=0.4, color='g')ax.bar(df_neg.index, df_minus['BLIP'], width=0.4, color='r')ax.autoscale()plt.show()這導(dǎo)致ValueError: shape mismatch: objects cannot be broadcast to a single shape整體解決方案df = base_dfplt.clf()fig = plt.figure()width = 8height = 6fig.set_size_inches(width, height)chart_title = 'YTD CR Trend Summary'df_plus =df[df['BLIP'] == 'XX']df_minus=df[df['BLIP']== 'IYY']p =  df_plus.resample('MS').count()['BLIP'].fillna(0)n = df_minus.resample('MS').count()['BLIP'].apply(lambda x: int(-x)) print(chart_title, len(df), p.sum(), n.sum())plt.clf()fig = plt.figure()# ax = fig.add_subplot(1, 1, 1)ax = plt.axes(label=chart_title) #label suppresses warningif p.sum() != False:    ax.bar(p.index, p, width=10, color='g') if n.sum() != False:    ax.bar(n.index, n, width=10, color='r')plt.suptitle(chart_title, fontsize=11)filename = f'{graph_images_dir}{chart_title}.png'print(f'Saving {filename}')plt.savefig(filename,  bbox_inches='tight', pad_inches=0.5, dpi=200)plt.show()
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 184 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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