I would imagine what I'm trying to do is fairly simple in pandas but I just can't get it.
Really I want to do this in dataframe-js
(or danfojs
) but any help in either pandas
or dataframe-js
will be helpful.
Essentially:
- there can be an array of any number of dataframes with any number of rows and columns.
- They should all have at least one matching column
uuid
. - Most of the dataframes will have data for every
uuid
but some might be missing. - The only known column name is
uuid
, so using "merge on" or similar with any other column name isn't an option.
example dataframes:
let data1 = [
[['col A', 'uuid'], ['1238', '12']],
[['col B', 'uuid'], ['42.4', '12']],
[['col A', 'uuid'], ['1091', '48']],
[['col B', 'uuid'], ['35.1', '48']],
[['col B', 'uuid'], ['44.4', '77']],
]
desired output (column order doesn't matter):
[
['col A', 'uuid', 'col B'],
['1238', '12', '42.4'],
['1091', '48', '35.1'],
[null, '77', '44.4'] // null, undefined, NaN...doesn't matter for the gaps
]
please help :)
Ok I combined @onyambu's answer with the
merge
function, which now accepts dataframes of different sizes