小编arm*_*amy的帖子

Matplotlib 饼图标签与值不匹配

我正在研究这个https://www.kaggle.com/edqian/twitter-climate-change-sentiment-dataset

\n

我已经将情绪从数字转换为其字符描述(即 0 将是中性,1 将是赞成,-1 将是反)

\n
import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\ntweets_df = pd.read_csv(\'twitter_sentiment_data.csv\')\n\ntweets_df.loc[tweets_df[\'sentiment\'] == 0, \'twt_sentiment\'] = \'Neutral\'\ntweets_df.loc[tweets_df[\'sentiment\'] == -1, \'twt_sentiment\'] = \'Anti\'\ntweets_df.loc[tweets_df[\'sentiment\'] == 1, \'twt_sentiment\'] = \'Pro\'\n\ntweets_df = tweets_df.drop([\'sentiment\'], axis=1) \n\n# display(tweets_df.head())\n                                                                                                                                              message             tweetid twt_sentiment\n0           @tiniebeany climate change is an interesting hustle as it was global warming but the planet stopped warming for 15 yes while the suv boom  792927353886371840          Anti\n1  RT @NatGeoChannel: Watch #BeforeTheFlood right here, as @LeoDiCaprio travels …
Run Code Online (Sandbox Code Playgroud)

python matplotlib bar-chart pandas pie-chart

5
推荐指数
1
解决办法
1407
查看次数

标签 统计

bar-chart ×1

matplotlib ×1

pandas ×1

pie-chart ×1

python ×1