i have the following dataframe:
High Low Open Close Volume Adj Close year pct_day
month day
1 1 NaN NaN NaN NaN NaN NaN 2010.0 0.000000
2 7869.853149 7718.482498 7779.655014 7818.089966 7.471689e+07 7818.089966 2010.0 0.007826
3 7839.965652 7719.758224 7775.396255 7777.940002 8.185879e+07 7777.940002 2010.0 0.002582
4 7747.175260 7624.540007 7691.152083 7686.288672 1.018877e+08 7686.288672 2010.0 -0.000744
5 7348.487095 7236.742135 7317.313616 7287.688546 1.035424e+08 7287.688546 2010.0 -0.002499
... ... ... ... ... ... ... ... ... ...
12 27 7849.846680 7760.222526 7810.902051 7798.639258 4.678145e+07 7798.639258 2009.5 -0.000833
28 7746.209996 7678.152204 7713.497907 7710.449358 4.187133e+07 7710.449358 2009.5 0.000578
29 7357.001540 7291.827806 7319.393874 7338.938345 4.554891e+07 7338.938345 2009.5 0.003321
30 7343.726938 7276.871507 7322.123779 7302.545316 3.967812e+07 7302.545316 2009.5 -0.000312
31 NaN NaN NaN NaN NaN NaN 2009.5 0.000000
Since it is not clear from the above pasted dataframe, below is a snapshot:
The months are in 1,2 3 ... Is it possible to rename the month index to Jan Feb Mar format?
Edit :
I am having a hard time implementing the example by @ChihebNexus
My code is as follows since it is a datetime :
full_dates = pd.date_range(start, end)
data = data.reindex(full_dates)
data['year'] = data.index.year
data['month'] = data.index.month
data['week'] = data.index.week
data['day'] = data.index.day
data.set_index('month',append=True,inplace=True)
data.set_index('week',append=True,inplace=True)
data.set_index('day',append=True,inplace=True)
df = data.groupby(['month', 'day']).mean()
strftime
. Take a look at docs.python.org/3/library/…. – JQadrad May 16 '20 at 19:53