-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Scatter requires x column to be numeric #18755
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
Related to #8113. Maybe we can pass x-values as it is? |
I tried commenting out the lines which raise the assertion: https://github.com/pandas-dev/pandas/blob/master/pandas/plotting/_core.py#L811 But then I got this:
The non-numeric columns seem to get dropped somehow? |
Adding to this. Looks like |
and @naught101 yeah, 'a' is getting dropped here |
Any way around this issue still using the plot function? |
I have the same error and it occurs only when there is a column of type |
I am also getting a same error |
@RahulRAhhy123 - I don't have a workaround for this. I wish I could use scatter directly from pandas with a jitter for the values. For some types of data, this is much clearer than a bar plot. |
What I did when I tried to plot a
2018-09-01 --> 2018.75 This isn't super accurate, nor is it pretty but it got the job done for me. |
I am running into this issue when trying to scatterplot with x and y both initially being lists of datetime objects, but I have a workaround using matplotlib directly: df = pd.DataFrame({'x':x,'y':y})
# Fails with 'ValueError: scatter requires x column to be numeric'
df.plot.scatter(x='x', y='y')
# Works, xdate=True is implicit
plt.plot_date(df['x'], df['y'], ydate=True) |
Some of the workarounds may work, but it's an inconvenient bug that I'm, and presumably others, are still encountering. Does anyone know if the actual bug is being address? |
I don't think anyone is working on this right now. Are you interested @jasonbono? |
That's good to know--thanks. I can't promise to try and fix it right now, but that is part of why I asked. |
you can convert datetime column to separate date, separate month and separate day column respectively. Finally, get rid of your datetime column and make sure new columns are of integer type. |
+1 |
take |
I encounter the same bug. I have two columns, both Timestamp, and I get this reply when I try to plot scatter:
|
This works, and produces this:
On the other hand, this doesn't:
Why does pandas require x to be numeric if matplotlib doesn't?
using versions from conda, on Kubuntu 17.10:
The text was updated successfully, but these errors were encountered: