waylonwalker
05/25/2022, 4:06 PMpython
node(lambda *frames: pd.concat(frames), ["cars", "cars"], "two_cars")
How would you concatenate pandas dataframes?antony.milne
05/25/2022, 4:17 PMpd.concat
takes a single iterable argument rather than *args
.
If you're doing this sort of thing a lot then you could probably a decorator that effectively does that conversion for you, but if it's just for pd.concat
then what you're doing here is the best you can do reallydatajoely
05/25/2022, 4:31 PMpy
node(pd.concat, ["cars", "cars2"], "two_cars")
Since it a sequence or mapping already https://pandas.pydata.org/docs/reference/api/pandas.concat.htmlwaylonwalker
05/25/2022, 7:40 PMdatajoely
05/25/2022, 7:56 PMwaylonwalker
05/25/2022, 8:17 PMdatajoely
05/25/2022, 8:17 PMwaylonwalker
05/25/2022, 8:21 PMdatajoely
05/25/2022, 8:21 PMwaylonwalker
05/25/2022, 8:22 PMdatajoely
05/25/2022, 8:23 PMwaylonwalker
05/25/2022, 8:23 PMdatajoely
05/25/2022, 8:26 PMwaylonwalker
05/25/2022, 8:26 PMdatajoely
05/25/2022, 8:27 PMwaylonwalker
05/25/2022, 8:27 PMantony.milne
05/25/2022, 9:54 PMimport functools
def inputs_to_sequence(func):
@functools.wraps(func)
def wrapper(*args):
return func(args)
return wrapper
pd.concat = inputs_to_sequence(pd.concat)
And then you can do directly
node(pd.concat, ["cars", "cars2"], "two_cars")
waylonwalker
05/25/2022, 9:56 PMantony.milne
05/25/2022, 10:01 PM**kwargs
I think, since the argument to pd.concat
could also be a mapping