Skip to content

Commit

Permalink
Add explicit copy for pandas>=2.1.0
Browse files Browse the repository at this point in the history
In Pandas 2.1.0 and later, there are several copy-on-write improvements
that cause beaking changes of the original copying mechanism, see:

    https://pandas.pydata.org/docs/dev/whatsnew/v2.1.0.html#copy-on-write-improvements

This commit ensures that the `_events` of leaf SummaryReader nodes will
be copied before constructing the full dataframe, preventing
involuntarily changing the data inside the `_events` dataframe.
  • Loading branch information
j3soon committed Nov 21, 2023
1 parent 2a902fa commit 59f1bac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tbparse/summary_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def get_events(self, event_type: str) -> pd.DataFrame:
dfs = []
if os.path.isfile(self.log_path):
# Leaf node appends events directly
dfs.append(self._events[event_type])
dfs.append(self._events[event_type].copy())
else:
# Non-leaf node collects children's events
for child in self._children.values():
Expand Down

0 comments on commit 59f1bac

Please sign in to comment.