-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Axes.violinplot has small issue in using pandas.DataFrame without index 0. #15272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is pretty similar to #15162 |
Can you give us a self-contained example? |
Probably should be changed to
|
Not really. Iterating over a DataFrame yields the column names. |
I assume somehow the column names have been resolved by this point? But I'm not familiar enough w/ pandas to concoct my own example |
Let's wait for an example. |
Sorry for the delay of reply. I have tried hard to make code and data small enough. The following is the code and data that might result in the error. import pandas as pd
import matplotlib.pyplot as plt
rdata = list()
for rname in ['one', 'two']:
tmp = pd.read_csv(rname + '.txt', sep='\t', header=None).set_index(0)
rdata.append(
tmp[1]
)
plt.violinplot(rdata) data in the code.However, if I reset the data index after reading, the error will not appear at all. import pandas as pd
import matplotlib.pyplot as plt
rdata = list()
for rname in ['one', 'two']:
tmp = pd.read_csv(rname + '.txt', sep='\t', header=None).set_index(0)
rdata.append(
tmp[1].reset_index(drop=True)
)
plt.violinplot(rdata) |
Bug report
Bug summary
When using pandas.DataFrame without index 0, the violinplot would raise KeyError.
Code for reproduction
In Axes method violinplot:
there a helper function using index 0, which is not convenient for pandas.DataFrame without index 0.
Actual outcome
Expected outcome
A violin plot.
Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineThe text was updated successfully, but these errors were encountered: