Avinash
Avinash

Reputation: 2191

how to plot graph for one pandas dataframe cell with respect to some columns

I am new to data plotting, matplotlib or sns library. There is a

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

y = np.random.rand(10,4)
y[:,0]= np.arange(10)
df = pd.DataFrame(y, columns=["X", "A", "B", "C"])

df.head()

enter image description here

df.plot(x='X', y=['A', 'B', 'C'], kind='bar')

enter image description here

How can I plot df.plot(y='1.0', x=['A', 'B', 'C'], kind='bar') # I want to put cell as X or Y axis.

I have copied the example from StackOverflow itself.

Upvotes: 0

Views: 2560

Answers (1)

in the code below, you can select row values and graph them by their types, you can do this for each row, and you can analyse each col/row you want with it.

#df.plot(x='X',y=['A','B','C'],kind = 'bar')
y1 = df.iloc[0,1:].values #for first column (horizontal values)
x1 = ['A','B','C']
plt.plot(x1,y1)

this one was for 0.th row,

Upvotes: 2

Related Questions