I have a pandas dataframe which looks like:
A B C D
1 2 3 4
5 6 7 8
9 10 11 12
And I need to plot all three rows and not columns. I know I can use iloc if I want a specific row but looking for something that could plot all rows together:
df.iloc[0]
I have also tried:
df.plot()
which plots columns A,B,... instead of rows.
NOTE: Number of rows is variable for different dataframes and could be up to 200 so I am not interested in setting colors or stuff like that
MatPlotLib with Python Make a 2D potentially heterogeneous tabular data using Pandas DataFrame class, where the column are x, y and equation. Get the reshaped dataframe organized by the given index such as x, equation, and y. Use the plot() method to plot the lines. To display the figure, use show() method.
Sometimes, we need to print all of the DataFrame's rows after constructing the DataFrames in “pandas. The “pandas” provides the “pd. set_option()” method for printing all rows of the DataFrame. We may use this technique for printing all rows of the DataFrame on the terminal.
Series can only contain single list with index, whereas dataframe can be made of more than one series or we can say that a dataframe is a collection of series that can be used to analyse the data.
You can transpose the dataframe and then plot to plot the rows
df.T.plot()
So, you're plotting columns of data vs rows? Sounds like you need to transpose your dataframe. Use df.T.plot()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With