Closed adrian-pace closed 6 years ago
@pykcel
df.set_index('Authors')
instead of df.index = df['Authors']
. Careful however because you won't have the column Authors anymore since it will be moved to the index df.index = df['Types']
The warning comes from :
df_add.columns += ' write/add'
and df_del.columns += ' del'
. I don't understand what you are trying to do. First you can't add column this way since you you are just changing the variable storing the columns names. Also you are actually trying to do str + list(str)
which is only possible if you have list(str)+list(str)
or str+str
. Anyway, as I said, you are modifying the variable holding the columns name, not adding a column. If you want to add a column you can try something like : df['write/add'] = [0]*df.shape[0]
.
If you want to just have a list of columns with a new element, copy the variable and use append
.
But I don't really understand what you are trying to do so I didn't touch that.
The idea here is that want to merge two dataframes in a way that they alternate for the palette colors of seaborn. I concatenate either write or del to every column names df_add.columns += ' write/add'
and we finally sort them in alphabetic order. This way we have the column author_1 write/add
followed by author_1 del
and so on for all authors.
I didn't manage to get the warning but if the issue comes from df_add.columns += ' write/add'
, I can find another way to rename the columns
I don't get the warning either with version 0.19.2 or 0.20.3 but I do with version 0.21.0. I suggest using pandas.DataFrame.rename
It should be fixed, you can confirm and close this issue
nice work
I get the warning
C:\Users\pace\Anaconda3\lib\site-packages\pandas\plotting_core.py:1714: 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
on pad : 753268753268753268753268753268753268