I am trying to get swarmplotby working with pandas. I have a 3d numpy arraycalled SIAggs, which I slice using pandasas follows:
rand_center = {('Random_dist'):SIAggs[:,:,1], ('Center_distance'):SIAggs[:,:,0]}
for key, value in rand_center.items():
rand_center[key] = pd.DataFrame(value)
sizes = {}
for i in range(size_iterations):
sizes.update({ (str(i+1)) : SIAggs[i,:,:] })
for key, value in sizes.items():
sizes[key] = pd.DataFrame(value)
df = pd.concat(sizes, rand_center, names = ['sizes', 'distance_measure'])
df.stack()
which when printed DataFramegives me:
sizes 1 2 3
distance_measure 0 1 0 1 0 1
0 -2.1881 1.262 -2.7001 1.493 -2.1381 1.626
1 -2.3671 1.699 -2.4431 1.208 -2.4571 1.186
2 -2.3071 0.716 -2.2841 1.122 -2.2441 1.396
3 -2.2521 0.967 -1.9451 1.496 -2.5261 1.690
4 -2.4651 1.800 -2.3421 1.500 -2.3571 0.985
5 -2.2011 1.409 -1.9921 0.160 -2.3701 1.114
6 -2.6911 0.915 -3.3301 1.510 -2.2561 1.676
7 -2.5751 1.128 -1.9931 0.941 -2.4411 1.605
8 -2.5321 1.651 -2.4751 1.145 -3.3541 1.228
9 -1.9741 0.886 -2.6671 1.196 -2.4581 1.321
which seems right.
then when I try to build it using swarmplotwhere I want Series(in my category sizes) paired (differences of shades using distance_measure)), basically just using the 5th example from seabornthe website
ax = sns.swarmplot(x = "sizes", hue = "distance_measure", data = df, split=True)
plt.show()
an error:
ax = sns.swarmplot(x = "sizes", hue = "distance_measure", data = df, split=True)
File "/Users/scottjg/anaconda/lib/python3.5/site-packages/seaborn/categorical.py", line 2679, in swarmplot
split, orient, color, palette)
File "/Users/scottjg/anaconda/lib/python3.5/site-packages/seaborn/categorical.py", line 1179, in __init__
self.establish_variables(x, y, hue, data, orient, order, hue_order)
File "/Users/scottjg/anaconda/lib/python3.5/site-packages/seaborn/categorical.py", line 147, in establish_variables
raise ValueError(err)
ValueError: Could not interpret input 'sizes'
Any help would be greatly appreciated. I can't make friends with pandas / seaborn, but I want to!