Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pass pandas dataframe as parameter to matplotlib library method plot

how to pass pandas dataframe as parameter to matplotlib library method plot ? For example

import matplotlib.pyplot as plt
plt.plot(df1.as_matrix(['Score']),df1.as_matrix(['Score']))
like image 424
Bala Avatar asked Dec 19 '25 11:12

Bala


1 Answers

It seems you need Series.values for convert Series to numpy array:

plt.plot(df1['Score'].values, df1['Col'].values)

Or use DataFrame.plot:

df.plot(x='Score',y='Col')
like image 89
jezrael Avatar answered Dec 21 '25 04:12

jezrael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!