I have built a DataFrame out of a Python dictionary, with the following command:
population=pd.DataFrame(population.items(),columns=['Date','population']).set_index('Date').sort_index(ascending=True)
That gave me the following frame population:
population
Date
2015-08 69
2015-09 65
2015-10 65
2015-11 66
2015-12 71
Out of that DataFrame I created another one with its moving average, using the following command:
population_movav=pd.rolling_mean(population,10)
That gave me the following frame population_movav:
population
Date
2015-08 68.0
2015-09 69.9
2015-10 71.6
2015-11 71.1
2015-12 71.2
I want to combine them so they get like this:
population population_movav
Date
2015-08 69 68.0
2015-09 65 69.9
2015-10 65 71.6
2015-11 66 71.1
2015-12 71 71.2
Synthesizing, I need to concatenate them and change the column name of the variable population_movav. Tried the pd.concat but for some reason it is not working out right.
Can someone shine some light on it?