You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 17, 2024. It is now read-only.
Is your feature request related to a problem? Please describe.
I'd like to merge DataFrames with different columns.
Describe the solution you'd like
I'd like to have a df1.merge(df2) way to automatically merge two dataframes, even if a column is in df1 but not in df2, filling it with
Describe alternatives you've considered
Here is a snippet from @lmeyerov I found (and completed) on issue #15, that makes just what I want :
functionunionDFs(a,b,fill='n/a'){// Merge two dataframes with different columnsconstaCols=a.listColumns();// this line was missing on lmeyerov's original snippetconstbCols=b.listColumns();// this line was missing on lmeyerov's original snippetconstaNeeds=b.listColumns().filter((v)=>aCols.indexOf(v)===-1);constbNeeds=a.listColumns().filter((v)=>bCols.indexOf(v)===-1);consta2=aNeeds.reduce((df,name)=>df.withColumn(name,()=>fill),a);constb2=bNeeds.reduce((df,name)=>df.withColumn(name,()=>fill),b);returna2.union(b2);}
Additional context
Current behaviour
What I'd like
The text was updated successfully, but these errors were encountered:
DataFrame.prototype.merge=function(df2,fill=null){// Merge two dataframes with different columnsconstaCols=df2.listColumns();constbCols=this.listColumns();constaNeeds=this.listColumns().filter((v)=>aCols.indexOf(v)===-1);constbNeeds=df2.listColumns().filter((v)=>bCols.indexOf(v)===-1);consta2=aNeeds.reduce((df,name)=>df.withColumn(name,()=>fill),df2);constb2=bNeeds.reduce((df,name)=>df.withColumn(name,()=>fill),this);returna2.union(b2);}
Is your feature request related to a problem? Please describe.
I'd like to merge DataFrames with different columns.
Describe the solution you'd like
I'd like to have a
df1.merge(df2)
way to automatically merge two dataframes, even if a column is in df1 but not in df2, filling it withDescribe alternatives you've considered
Here is a snippet from @lmeyerov I found (and completed) on issue #15, that makes just what I want :
Additional context
Current behaviour
What I'd like
The text was updated successfully, but these errors were encountered: