1

df

SKU   A    B  Jan_Sales  Feb_Sales  Mar_sales Apr_sales  Dec_sales..
 A    AC   BA      122        100        50        200         300
 B    BC   BB      100        50         80        90          250
 C    CC   BC       40        30        100        10          11

and so on

Now I want a graph which will plot Jan sales, feb sales and so on till dec in one line for SKU A, Similarly one line on the same graph for SKU B and same way for SKU C. I want to drop columns A and B. I know how to do that using column name, but how can i do that using column number/position

df.set_index("SKU").drop(['A','B']).T.plot()

How to drop A and B using their position 1 and 2 in this case

noob
  • 3,601
  • 6
  • 27
  • 73
  • Does this answer your question? [How to get column by number in Pandas?](https://stackoverflow.com/questions/17193850/how-to-get-column-by-number-in-pandas) – Mykola Zotko Jan 30 '20 at 09:40

1 Answers1

1

Add DataFrame.iloc for remove first and second columns, here A and B:

df.set_index("SKU").iloc[:, 2:].T.plot()
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252