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
This would be the fix: var_list = var_create(*args or __data.columns).
And with some context and a doctest:
@singledispatch2(pd.DataFrame)defgather(__data, key, value, *args, drop_na=False, convert=False):
"""Reshape table by gathering it in to long format. Examples -------- >>> import pandas as pd >>> from siuba import _, gather >>> df = pd.DataFrame({"x": [1, 2], "y": [3, None]}) >>> gather(df, key="key", value="value") key value 0 x 1.0 1 x 2.0 2 y 3.0 3 y NaN """# TODO: implement var selection over *argsifconvert:
raiseNotImplementedError("convert not yet implemented")
# TODO: copied from nest and selectvar_list=var_create(*argsor__data.columns) # <-- this is the fixod=var_select(__data.columns, *var_list)
value_vars=list(od) orNoneid_vars= [colforcolin__data.columnsifcolnotinod]
long=pd.melt(__data, id_vars, value_vars, key, value)
ifdrop_na:
returnlong[~long[value].isna()].reset_index(drop=True)
returnlong
However there is a TODO and maybe you want to implement a more systematic solution.
The docs for
gather
state for*args
:However, if not
*args
are specified, nothing is selected.Code to reproduce this:
The text was updated successfully, but these errors were encountered: