Feb-23-2017, 12:56 PM
Hi Pandas Experts,
I got a dataframe that has a country and its GDP for the year 2015 up to 2006
KeyError: '[ 4.80566748e+12 1.75626949e+12 1.73021626e+11 2.46702696e+11\n 2.30356251e+11 2.28139911e+11 3.52665152e+11 1.10131180e+12\n 1.53345695e+11 3.25560528e+11 -1.52854060e+11 4.99867550e+09\n nan 2.79311766e+11 4.74343726e+11] not in index'
It seems the GDP values are not an/in index but I wonder why that is required?
Why does a column need to be an index to be subtracted from another?
Many thanks for any explanations
I got a dataframe that has a country and its GDP for the year 2015 up to 2006
newfour = newtwo[(newtwo['2015']-newtwo['2006'])]When I try to substract 2015 from 2006 and ingone the rest I read the error:
KeyError: '[ 4.80566748e+12 1.75626949e+12 1.73021626e+11 2.46702696e+11\n 2.30356251e+11 2.28139911e+11 3.52665152e+11 1.10131180e+12\n 1.53345695e+11 3.25560528e+11 -1.52854060e+11 4.99867550e+09\n nan 2.79311766e+11 4.74343726e+11] not in index'
It seems the GDP values are not an/in index but I wonder why that is required?
Why does a column need to be an index to be subtracted from another?
Many thanks for any explanations