Wednesday, 4 September 2013

Pandas reset index on series to remove multiindex

Pandas reset index on series to remove multiindex

I accidentally created a series from a Dataframe, when I resampled some
data with a count like so where H2 is a DF:
H3=H2[['SOLD_PRICE']]
H5=H3.resample('Q',how='count')
H6=pd.rolling_mean(H5,4)
This yielded a series that looks like this:
1999-03-31 SOLD_PRICE NaN
1999-06-30 SOLD_PRICE NaN
1999-09-30 SOLD_PRICE NaN
1999-12-31 SOLD_PRICE 3.00
2000-03-31 SOLD_PRICE 3.00
with an index that looks like:
MultiIndex
[(1999-03-31 00:00:00, u'SOLD_PRICE'), (1999-06-30 00:00:00,
u'SOLD_PRICE'), (1999-09-30 00:00:00, u'SOLD_PRICE'), (1999-12-31
00:00:00, u'SOLD_PRICE'),.....
I don't want/need the second col as an index or part of one. Ideally I'd
have a DF with col 1 as "Date" and col 2 as "Sales" (dropping the current
col 2). I don't quite see how to reconfigure the index. and series or DF?

No comments:

Post a Comment