Search code examples
pandaschartsline

How can i create a line chart of a specific row from my table in PANDAS?


      PARENT    Week    Month   Weekend
---------------------------------------
1010D   AX1      665    1633    687
1009A   BX1     1372    1484    1173 
1013B   CX1      895     941    777 
1007B   DX1      829     932    773

This is my mydata.csv. (sorry i couldn't align the row values under specific columns asking the question with stackoverflow format. @glhr

How can a draw a line chart of BX1 under NAME column for values of Week, Month and Weekend using Pandas?


Solution

  • If only unique value BX1 value after filtering by boolean indexing transpose and add DataFrame.squeeze for convert one column DataFrame to Series and plot by plot.bar:

    df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot.bar()
    

    Or:

    df.loc[df['NAME'] == 'BX1', ['Week','Month','Weekend']].T.squeeze().plot()