Home > Mobile >  Plotting a pyplot graph with a single column of Data [duplicate]
Plotting a pyplot graph with a single column of Data [duplicate]

Time:10-05

I have a data of CSV format which consists of 9 columns and over 900000 rows. What should I do in order to plot the graph for a single column from a particular range of rows? eg: To plot the graph from 12th to the 29000th row. I had previously used pyplot to plot the graph and pandas to read the csv files.

CodePudding user response:

Let's assume your column is named Column. Then you would slice your dataframe and create a plot using:

plt.plot(df.loc[11:28999, 'Column'])

Without more information it's difficult to give a more complete answer.

To accept user input for these columns, simply do:

start_row = input('Please enter starting row: ')
end_row = input('Please enter ending row: ')

plt.plot(df.loc[start_row:end_row, 'Column'])
  • Related