I have used pd.pivot_table
in pandas dataframe, and the column names becomes tuples like ('A1', 'B1'), ('A1', 'B2'), ...
, and I want them to be like 'A1_B1', 'A1_B2', ...
I tried to use
df.columns.values[i] = df.columns.values[i][0] + '_' + df6.columns.values[i][1],
and tried rename
as well.
When I checked df.columns.values
, the column names changed, but when I cannot use these names to do indexing. I am new to python, so might not know the difference between column names and column indices.
df.rename()
method above? – Flaccid