Category : pandas

Supposed we have a df with a sum() value in the below DataFrame, thanks so much for @jezrael ‘s answer here, but we have many different df like below DataFrame with different columns df.columns=[‘value_a’,’value_b’,’name’,’up_or_down’,’difference’] df.loc[‘sum’] = df[[‘value_a’,’value_b’,’difference’]].sum() df1 = df[[‘value_a’,’value_b’,’difference’]].sum().to_frame().T df = pd.concat([df1, df], ignore_index=True) df value_a value_b name up_or_down difference project_name 27.56 25.04 -1.31 ..

Read more

Currently, I create separate df and finally concat these df to create a single dataframe. import numpy as np import pandas as pd blist_l=[‘a’,’b’,’c’,’d’,’e’] nlabel_l=[‘dis_label’] rt_l=[‘re’,’rq’] N=100 nlist=[np.random.rand(5) for _ in range(N)] nlabel=np.random.randint(3,size=N) rt=np.random.rand(N,2) df1=pd.DataFrame(nlist,columns=blist_l) df2=pd.DataFrame(nlabel,columns=nlabel_l) df3=pd.DataFrame(rt,columns=rt_l) df=pd.concat([df2,df3,df1],axis=1) Is there elegant or one liner to create a df from a list of array, and, multiple ..

Read more

I have a dataframe "expeditions" where there are 3 columns ("basecamp_date", "highpoint_date" and "termination_date"). I would like to check that the basecamp date is before the highpoint date and before the termination date because I noticed that there are rows where this is not the case (see picture) Do you have any idea what I ..

Read more