我在使用熊猫融化时遇到一些困难。我尝试按照鸢尾花示例处理数据集,但最终得到一个无法解释的数据框。这也不是我希望得到的。
我的数据集如下:
Type Airline Count
0 neutral Virgin America 171
1 positive Virgin America 152
2 negative Virgin America 181
3 positive United 492
4 negative United 2633
5 neutral United 697
6 negative Southwest 1186
7 neutral Southwest 664
8 positive Southwest 570
9 positive Delta 544
10 neutral Delta 723
11 negative Delta 955
12 negative US Airways 2263
13 neutral US Airways 381
14 positive US Airways 269
15 negative American 1960
16 neutral American 463
17 positive American 336
但是我收到的结果是:
Type Airline value
0 neutral Airline Virgin America
1 positive Airline Virgin America
2 negative Airline Virgin America
3 positive Airline United
4 negative Airline United
5 neutral Airline United
6 negative Airline Southwest
7 neutral Airline Southwest
8 positive Airline Southwest
9 positive Airline Delta
10 neutral Airline Delta
11 negative Airline Delta
12 negative Airline US Airways
13 neutral Airline US Airways
14 positive Airline US Airways
15 negative Airline American
16 neutral Airline American
17 positive Airline American
18 neutral Count 171
19 positive Count 152
20 negative Count 181
21 positive Count 492
22 negative Count 2633
23 neutral Count 697
24 negative Count 1186
25 neutral Count 664
26 positive Count 570
27 positive Count 544
28 neutral Count 723
29 negative Count 955
30 negative Count 2263
31 neutral Count 381
32 positive Count 269
33 negative Count 1960
34 neutral Count 463
35 positive Count 336
所以当我尝试使用swarmplot时,我得到了错误。
ValueError: Could not interpret input 'Count'
下面是我正在使用的代码,
airline_data = pd.melt(airline_data, "Type", var_name="Airline")
print(airline_data)
# Draw a categorical scatterplot to show each observation
sns.swarmplot(x="Airline", y="Count", hue="Type",
palette=["r", "c", "y"], data=airline_data)
我希望得到的结果是创建一个像虹膜数据集中的水样图。