Source From Here
QuestionI am trying to create a scatter plot from pandas dataframe, and I dont want to use matplotlib plt for it. Following is the script:
- df:
- group people value
- 1 5 100
- 2 2 90
- 1 10 80
- 2 20 40
- 1 7 10
- df.plot.scatter(x = df.index, y = df.value)
how to perfom this plot with pandas dataframe
HowTo
You can try and use:
- import pandas as pd
- df = pd.DataFrame(list(range(7)), columns=['value'])
- df.reset_index().plot.scatter(x='index', y='value')
- import matplotlib.pyplot as plt
- plt.scatter(df.index, df.value)
- plt.xlabel("index")
- plt.ylabel("value")
- plt.show()
沒有留言:
張貼留言