Skip to content

Commit

Permalink
WIP: fix passing block manager to frame or series
Browse files Browse the repository at this point in the history
  • Loading branch information
theOehrly committed Feb 4, 2024
1 parent fd2fb60 commit 90eaf9d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion fastf1/internals/pandas_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
)

import pandas as pd
# dangerous! some way around this would be better
from pandas.core.internals import (
BlockManager,
SingleBlockManager
)


class BaseDataFrame(pd.DataFrame):
Expand Down Expand Up @@ -97,7 +102,12 @@ def __new__(cls, data=None, index=None, *args, **kwargs) -> pd.Series:
# the data is a row of the parent DataFrame
constructor = parent._constructor_sliced_horizontal

obj = constructor(data=data, index=index, *args, **kwargs)
if (isinstance(data, (BlockManager, SingleBlockManager))
and hasattr(constructor, '_from_mgr')
and pd.__version__.startswith('2.')):
obj = constructor._from_mgr(data, axes=data.axes)
else:
obj = constructor(data=data, index=index, *args, **kwargs)

if parent is not None:
# catch-all fix for some missing __finalize__ calls in Pandas
Expand Down

0 comments on commit 90eaf9d

Please sign in to comment.