简体   繁体   中英

Pandas - All I want is a single series value output with not other metadata

I have 2 dataframes that I have successfully merged together which results in a single desired row of data.

Then I successfully determined the whole value difference between two integer columns.

Now all I want to do is output the integer value result, with no other metadata.

IN:

def answer_four():

Top15 = answer_one()
Top15_6th = answer_three()
Top15_6th = Top15_6th.iloc[[5]]

# https://stackoverflow.com/questions/36538780/merging-dataframes-on-index-with-pandas

Top15_6th_ab = pd.merge(
                           Top15_6th[['avgGDP']],
                           Top15[['2006', '2007', '2008', '2009', '2010', '2011', '2012', '2013', '2014', '2015']],
                           left_index = True,
                           right_index = True
                       )

Top15_6th_ab['Value_10yr_Change'] = Top15_6th_ab['2015'] - Top15_6th_ab['2006'] 

return Top15_6th_ab['Value_10yr_Change']

answer_four()

OUT:

Country
United Kingdom 246702696075
Name: Value_10yr_Change, dtype: float64

All I want in OUT is:

246702696075

I assume I need to add some method/parameters after my return clause, but through much research I have found the answer.

Thanks for your time and assistance in advance!

Matt

Top15_6th_ab['Value_10yr_Change'][0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM