0

I want to get rid of column/column name from pandas dataframe that I get after using pivot. I am not sure

temp = {'NOL' : [2016,2016,2016,2017, 2017, 2017],
   'A1': ['M1','M2', 'M3','M1','M2', 'M3'],
   'Val':[100, 110, 130, 140, 150, 160]}
dd = pd.DataFrame(temp)
dd2 = dd.pivot(index = 'A1', columns = 'NOL', values='Val').reset_index()

dd2.columns give me Index(['A1', 2016, 2017], dtype='object', name='NOL')

Here I want to get rid of NOL index or column with NOL. I've tried options here. with dd2.index.name = None and del dd2.index.name but it does not work.

cs95
  • 330,695
  • 80
  • 606
  • 657
user1430763
  • 37
  • 1
  • 8
  • 1
    Are you referring to the columns name attribute? if so then you want `dd2.columns.name = None` There is a dupe of this somewhere – EdChum Oct 04 '17 at 14:54
  • 1
    @cᴏʟᴅsᴘᴇᴇᴅ you are really good at finding dupes. : ) – Bharath Oct 04 '17 at 15:00

0 Answers0