I have these data sets (A) Emissions Year Country Continent Emission 0 2008 Aruba South America 24.750133 1 2009 Aruba South America 24.876706 2 2010 Aruba South America 24.182702 3 2011 Aruba South America 23.922412 4 2008 Andorra Europe 6.296125 .. ... ... ... ... 783 2011 Zambia Africa 0.212450 784 2008 Zimbabwe Africa 0.569255 785 2009 Zimbabwe Africa 0.600521 786 2010 Zimbabwe Africa 0.646073 787 2011 Zimbabwe Africa 0.691698 (B) Gap_long Country Year Population 0 Afghanistan 2008 27700000 1 Albania 2008 3000000 2 Algeria 2008 34700000 3 Andorra 2008 83900 4 Angola 2008 21700000 .. ... ... ... 775 Venezuela 2011 28900000 776 Vietnam 2011 88900000 777 Yemen 2011 23800000 778 Zambia 2011 14000000 779 Zimbabwe 2011 12900000 Using pandas in python code How do I create a new dataframe that only contains the rows that were present in both emissions and gap_long . Name this dataframe emissions_both. I was given this Hint by another user: Looking at the _merge column may be helpful. I have tried over and over again and all I get is either an error or a wrong answer. The error states that "AssertionError: Your dataframe dimensions are incorrect. Are you selecting rows that present in both dataframes?" Please help. I have tried over and over again and all I get is the assertion error
I have these data sets
(A) Emissions
Year Country Continent Emission 0 2008 Aruba South America 24.750133 1 2009 Aruba South America 24.876706 2 2010 Aruba South America 24.182702 3 2011 Aruba South America 23.922412 4 2008 Andorra Europe 6.296125 .. ... ... ... ... 783 2011 Zambia Africa 0.212450 784 2008 Zimbabwe Africa 0.569255 785 2009 Zimbabwe Africa 0.600521 786 2010 Zimbabwe Africa 0.646073 787 2011 Zimbabwe Africa 0.691698
(B) Gap_long
Country Year Population 0 Afghanistan 2008 27700000 1 Albania 2008 3000000 2 Algeria 2008 34700000 3 Andorra 2008 83900 4 Angola 2008 21700000 .. ... ... ... 775 Venezuela 2011 28900000 776 Vietnam 2011 88900000 777 Yemen 2011 23800000 778 Zambia 2011 14000000 779 Zimbabwe 2011 12900000
Using pandas in python code
How do I create a new dataframe that only contains the rows that were present in both emissions and gap_long . Name this dataframe emissions_both. I was given this Hint by another user: Looking at the _merge column may be helpful. I have tried over and over again and all I get is either an error or a wrong answer. The error states that "AssertionError: Your dataframe dimensions are incorrect. Are you selecting rows that present in both dataframes?" Please help. I have tried over and over again and all I get is the assertion error
Step by step
Solved in 3 steps with 1 images