-1

I have a data set following columns:

Country

Gdp

Life Satisfaction

I want to group on country and GDP. I want GDP col in a list names X and Life Satisfaction in list Y to create scatter plot.

Using this I am able to group:

df=dataSet.groupby(["Country","Gdp Per Capita"])

But df is generic.DataFrame.GroupBy

How can I extend my code to take values in X and Y.

Community
  • 1
  • 1
  • Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on how to ask a good question may also be useful. – yatu May 09 '19 at 08:32

1 Answers1

1

If I understood the question correctly:

df=dataSet.groupby(["Country","Gdp Per Capita"], as_index=False).mean()
X = df['Gdp Per Capita'].to_list()
Y = df['Life Satisfaction'].to_list()
Paresh
  • 654
  • 5
  • 7