BUG: scatter plot with categorical data raises KeyError · Issue #16199 · pandas-dev/pandas (original) (raw)
df = pd.DataFrame({'x':[1,2,3,4], 'y':pd.Categorical(['a', 'b', 'a', 'c'])}) df.plot(x='x', y='y', kind='scatter')
raises KeyError: 'y'
, while the column certainly exists, which can be very confusing.
Without the scatter (just df.plot(x='x', y='y')
), it raises the more informative TypeError: Empty 'DataFrame': no numeric data to plot