1

I'm getting a UserWarning when plotting a dataframe.

UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
series.name = label

I've went to the web link and can't seem to find what I'm doing wrong. My code is as follows:

f, axs = plt.subplots(4, sharex=True)
df.plot('time', ['a', 'b'], color=['red','blue'], ax=axs[0])

It gives the warning on the second line above.

df.head(1) returns data in the format below. Any single plot I do with this dataframe gives the same error.

  time       b        a        bR     aR       bS    bS4  \
0 12:00:00   601.61   601.99   nan    601.92   775   975   

   bS8  bS16    aS2 ...   aRa_8  aRa_16    \
0  1373 2396    1340 ...  5      5

  [1 x 45 columns]
Supez38
  • 329
  • 1
  • 3
  • 16
  • Please update with the full error traceback, and `df.head(1)`, so we can see what you're working with? – G. Anderson Nov 26 '18 at 22:19
  • It doesn't give me a traceback, just tells me that the error comes from that in pandas/plotting/_core.py:1714 – Supez38 Nov 26 '18 at 22:24
  • 1
    I don't get an error or warning running your code on dummy data, `df=pd.DataFrame({'a':[1,2,3,4,5],'b':[0,9,8,7,6],'c':[2,4,6,8,0]})`, what does the real data look like? – G. Anderson Nov 26 '18 at 22:37
  • I added the data above with dummy names and values. – Supez38 Nov 27 '18 at 15:38
  • Again, I am just not seeing a warning. Even if I insert `NaN` values and time data. Are you getting plots and it just warns, or does it not plot? And is `series.name = label` anywhere in your code? – G. Anderson Nov 27 '18 at 15:57
  • Plots come out just fine, it just gives me a warning at the top. "series.name = label" is code in pandas core. Is there anyway to suppress the warning? – Supez38 Nov 27 '18 at 16:02
  • I just found this: https://github.com/pandas-dev/pandas/issues/18671 and https://github.com/pandas-dev/pandas/issues/18764 – Supez38 Nov 27 '18 at 16:03
  • [Here's](https://stackoverflow.com/questions/48828824/disable-warnings-in-jupyter-notebook) a question and answer regarding supressing warnings – G. Anderson Nov 27 '18 at 16:09

0 Answers0