1

I have a data frame df which looks like:

        date                    day
0 2016-01-29     value    14.108988  dtype: float64
1 2016-02-01     value    20.689517  dtype: float64
2 2016-02-02     value    52.076471  dtype: float64
3 2016-02-03     value    -1.750325  dtype: float64
4 2016-02-04     value  -158.166786  dtype: float64

My question is how do I remove the 'value' and 'dtype: float64' from each row of the dataframe so I am left with :

        date           day
0 2016-01-29     14.108988  
1 2016-02-01     20.689517  
2 2016-02-02     52.076471  
3 2016-02-03     -1.750325  
4 2016-02-04   -158.166786  

The dataframe df is filled in the following way below is the head of another dataframe called timeseriesData :

                               MTAA   \
date                                                            
2015-12-25                       NaN                       
2015-12-26                       NaN                         
2015-12-28                     41.15                       
2015-12-29                     42.27                       
2015-12-30                     42.09

I iterate through the index to get the date used in the date column of the dataframe using:

for index, row in timeseriesData.iterrows():
                day = index

the day value is created from the following perf dataframe:

perf    value
id           
0   -0.000000
1   -0.000000
2   -0.000000
3   -0.000000
4   -0.000000
5   32.048692
6   -0.000000
7   -0.000000
9   -0.000000
10 -73.147585

using:

perf.sum()

I've not seen this before and have looked for a solution but not found one.

Why do I have 'value' and the datatype and how can I remove them?

halfer
  • 19,824
  • 17
  • 99
  • 186
Stacey
  • 4,825
  • 17
  • 58
  • 99
  • 2
    The question should be how to avoid this in the first place ? How do you create your dataframe ? – polku Aug 31 '16 at 15:47
  • It's not clear what your dataframe is. Can you show `df.iloc[0,0]` and `df.iloc[0,1]`? (I assume it has two columns.) – IanS Aug 31 '16 at 15:47
  • created with df = pd.DataFrame(columns=('date','day_performance')) and filled using df.loc[len(df)]=[day,perf.sum()] – Stacey Aug 31 '16 at 16:07
  • That looks strange. Can you edit the original question and show what `day` and `perf` are? – IanS Aug 31 '16 at 16:22
  • Still quite strange. You need to post a [MCVE]. Right now it is not possible to reproduce your problem with the information provided. This will help with pandas specifically: [How to make good reproducible pandas examples](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – IanS Sep 01 '16 at 07:05

0 Answers0