python - Dataframe reindex on a column -


this dataframe

      ticker        date   datevalue 549      rcg  2015-01-02    10 692      rcg  2015-01-05    8 

i want have have reindex

foo =  foo.reindex(index=['2015-01-01', '2015-01-02'])  ticker        date   datevalue rcg  2015-01-01    n/a rcg  2015-01-02    10 

instead get

       ticker date   datevalue 2015-01-01    nan  nan          nan 2015-01-02    nan  nan          nan 

you can set index:

df = pd.dataframe({'ticker': ['rcg','rcg'], 'date': ['2015-01-02','2015-01-05'], 'datevalue':[10,8]}, index=[549, 692]) df.set_index('date', inplace=true) print(df)              datevalue ticker date                         2015-01-02         10    rcg 2015-01-05          8    rcg 

is expected result ?


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -