Mar-03-2017, 06:05 PM
Dear Python Experts,
I am looking and Daniel Breen´s project* about housing prices and GDP in the US.
I noticed about half way through In [37] he is doing the following:
economy_df['Next Quarter GDP'] = list(economy_df['GDP (billions)'].iloc[1:]) + [np.NAN]
economy_df['Two Quarters GDP'] = list(economy_df['GDP (billions)'].iloc[2:]) + 2*[np.NAN]
It seems that the first line goes down one row and takes the value and puts it in a column while
the second line takes the value from two rows down and puts it in a column.
Code wise I dont really understand it. Why the list? What does the np.NAN do?
When I take the list(...) away the whole thing does not go down 1 or 2 rows anymore.
Is there another way to achieve the same functionality?
Many thanks for any ideas and a great weekend.
*http://danielbreen.net/projects/housing_prices_college_towns/
I am looking and Daniel Breen´s project* about housing prices and GDP in the US.
I noticed about half way through In [37] he is doing the following:
economy_df['Next Quarter GDP'] = list(economy_df['GDP (billions)'].iloc[1:]) + [np.NAN]
economy_df['Two Quarters GDP'] = list(economy_df['GDP (billions)'].iloc[2:]) + 2*[np.NAN]
It seems that the first line goes down one row and takes the value and puts it in a column while
the second line takes the value from two rows down and puts it in a column.
Code wise I dont really understand it. Why the list? What does the np.NAN do?
When I take the list(...) away the whole thing does not go down 1 or 2 rows anymore.
Is there another way to achieve the same functionality?
Many thanks for any ideas and a great weekend.
*http://danielbreen.net/projects/housing_prices_college_towns/