Patching Dec 9, 2021 6-7a CST- All GitLab services may be unavailable for 5-10 minutes

Commit efdeadca authored by Matthew Krafczyk's avatar Matthew Krafczyk
Browse files

Fix two bugs brought about by tuples and multiindex columns

parent acee2ca5
......@@ -246,8 +246,9 @@ def sequence_df(df, lags, group_specs=None):
# Change column types to support nans
integer_columns = temp_df.dtypes[temp_df.dtypes.apply(pd.api.types.is_integer_dtype)]
for col_name in integer_columns.index:
temp_df.loc[:,col_name] = temp_df.loc[:,col_name].astype(pd.Int64Dtype())
temp_df.loc[:,[col_name]] = temp_df.loc[:,[col_name]].astype(pd.Int64Dtype())
# Strip multiindex columns if needed
if (by is None) and (level is None):
# No need to group the DataFrame here.
temp_gbydf = temp_df
......@@ -263,7 +264,7 @@ def sequence_df(df, lags, group_specs=None):
if slice_df is not None:
if len(slice_df) == 0:
raise ValueError(f"No data at lag {lag}")
slice_df.columns = pd.MultiIndex.from_product([slice_df.columns,[lag]])
slice_df.columns = pd.MultiIndex.from_product([slice_df.columns.tolist(),[lag]])
dfs.append(slice_df)
# Join segments into full dataframe.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment