pandas - Python: Merging many dataframes in most efficient way possible -


right have many different statistics names attached in separate dataframes. in order merge have keep rewriting new dataframe? there more efficient way this?

does pd.merge make easier if names of columns same when merging?

do have recursively write

pd.merge(left=something, right=somethingelse, left_on='name', right_on='site') 

you can first creating list of dataframes , rsult using reduce function

# create data columns = ['v1','v2','v3'] df1 = pd.dataframe(np.random.randint(10, size=(3,3)),columns=columns) df2 = pd.dataframe(np.random.randint(10, size=(3,3)),columns=columns) df3 = pd.dataframe(np.random.randint(10, size=(3,3)),columns=columns)  dfs = [df1,df2,df3] # store in 1 list df_merge = reduce(lambda  left,right: pd.merge(left,right,on=['v1'], how='outer'), dfs) 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -