0

I am calling an API that returns me a dataframe. When i do print(df) it prints something like this,

             val1    val2    val3     val4    val5      
Date                                                         
2019-07-29   415.75  433.00  435.35   433.00  435.35   
2019-07-30   429.35  433.00  438.70   433.00  435.35   
2019-07-31   425.35  423.90  430.20   433.00  435.35   
2019-08-01   424.60  423.25  426.35   433.00  435.35   
2019-08-02   417.05  413.90  417.85   433.00  435.35   
2019-08-05   410.60  403.65  406.65   433.00  435.35   
2019-08-06   402.65  401.00  411.50   433.00  435.35 

Now I have a new entry like 2019-08-07, val1=500, val2=501, val3=502 that i need to add to the end of the dataframe so that it should look like below when i do print(df). For columns which are not populated it should be nan. Please let me know how to do that.

             val1    val2    val3     val4    val5      
Date                                                         
2019-07-29   415.75  433.00  435.35   433.00  435.35   
2019-07-30   429.35  433.00  438.70   433.00  435.35   
2019-07-31   425.35  423.90  430.20   433.00  435.35   
2019-08-01   424.60  423.25  426.35   433.00  435.35   
2019-08-02   417.05  413.90  417.85   433.00  435.35   
2019-08-05   410.60  403.65  406.65   433.00  435.35   
2019-08-06   402.65  401.00  411.50   433.00  435.35 
2019-08-07   500.00  501.00  502.00   nan     nan  
Thomas
  • 489
  • 1
  • 8
  • 13
  • Also: https://stackoverflow.com/questions/46621712/add-a-new-row-to-a-pandas-dataframe-with-specific-index-name – harvpan Aug 26 '19 at 15:06
  • Closed as duplicate question and the above one are not addressing the problem of some variables being unknown. Voting to reopen. – Roman Luštrik Aug 27 '19 at 06:29

0 Answers0