Home > Software engineering >  I am trying to append two dataframes but its giving an empty dataframes
I am trying to append two dataframes but its giving an empty dataframes

Time:05-05

Here is the code:

with open('Epoch_SN001.pickle','rb') as f:
    p=pickle.load(f)
    p_des=p.describe()
    print(type(p_des))
    print(p_des)
    epoch_count=set(p.epoch)
    p_deddf=pd.DataFrame()
    p_deddf.append(p_des)
    print(p_deddf)
    print(type(p_deddf))
    
And here is the output: 
<class 'pandas.core.frame.DataFrame'>
               time         epoch     EEG F4-M1     EEG C4-M1     EEG O2-M1  \
count  6.566400e 06  6.566400e 06  6.566400e 06  6.566400e 06  6.566400e 06   
mean   1.499805e 04  4.270000e 02 -8.755249e-05 -1.536531e-04 -1.913667e-04   
std    8.660254e 03  2.468171e 02  2.037796e 01  1.805393e 01  1.607171e 01   
min    0.000000e 00  0.000000e 00 -7.568231e 02 -6.949228e 02 -8.946693e 02   
25%    7.499000e 03  2.130000e 02 -7.433540e 00 -6.091237e 00 -5.534189e 00   
50%    1.499800e 04  4.270000e 02 -4.388772e-02  2.513637e-01  2.564227e-01   
75%    2.249700e 04  6.410000e 02  7.201991e 00  6.419278e 00  5.887075e 00   
max    2.999600e 04  8.540000e 02  8.028337e 02  7.442678e 02  7.758796e 02   

          EEG C3-M2      EMG chin     EOG E1-M2     EOG E2-M2           ECG  
count  6.566400e 06  6.566400e 06  6.566400e 06  6.566400e 06  6.566400e 06  
mean  -1.968810e-04  5.904567e-05 -3.301268e-05 -3.738243e-05 -8.534347e-04  
std    2.138014e 01  3.507483e 00  2.183542e 01  2.047519e 01  1.211850e 02  
min   -1.229268e 03 -1.960828e 02 -1.196565e 03 -1.181895e 03 -2.716338e 03  
25%   -6.098073e 00 -1.090589e 00 -5.947205e 00 -5.361692e 00 -3.240427e 01  
50%    6.228285e-02  3.518932e-03  1.164838e-01  8.771005e-02  1.894358e 00  
75%    6.232297e 00  1.093312e 00  6.074414e 00  5.452523e 00  3.597804e 01  
max    7.703818e 02  3.637456e 02  7.661736e 02  7.630741e 02  2.490308e 03  
Empty DataFrame
Columns: []
Index: []
<class 'pandas.core.frame.DataFrame'>

I have several other files and need to append the p.des() add to a data frame and save it in an excel file for further and future use. Any insights over this error will be appreciated.

Thank you!

CodePudding user response:

p_deddf.append(p_des)

append returns a copy of the dataFrame rather updating the dataFrame inplace.
try: p_deddf = p_deddf.append(p_des)

  • Related