@@ -19,7 +19,8 @@ change logging to a Series or DataFrame.
1919
2020The pattern is always the same: call ``startlog() `` before an operation and
2121``endlog() `` after it. ``endlog `` logs how the data changed — rows or columns
22- added/removed or, when the shape is unchanged, how many cell values changed.
22+ added/removed (followed by the resulting shape) or, when the shape is unchanged,
23+ how many cell values changed.
2324
2425``startlog(clone=False) ``
2526 Snapshots the current shape (and a timestamp). Pass ``clone=True `` to also
@@ -85,17 +86,17 @@ Removing rows, filtering, or dropping columns changes the shape, which is
8586logged automatically:
8687
8788>>> _ = df.raffa.startlog().dropna(subset = [" bill_depth_mm" ]).raffa.endlog(timeit = False )
88- Removed 2/10 (20.00%) rows.
89+ Removed 2/10 (20.00%) rows. New shape: (8, 8).
8990>>> _ = df.raffa.startlog().query(" species=='Adelie'" ).raffa.endlog(timeit = False )
90- Removed 5/10 (50.00%) rows.
91+ Removed 5/10 (50.00%) rows. New shape: (5, 8).
9192>>> _ = df.raffa.startlog().drop([" bill_length_mm" , " bill_depth_mm" ], axis = 1 ).raffa.endlog(timeit = False )
92- Removed 2/8 (25.00%) columns.
93+ Removed 2/8 (25.00%) columns. New shape: (10, 6).
9394
9495With the default ``timeit=True ``, ``endlog `` appends the elapsed time on a
9596second line (the duration varies from run to run):
9697
9798>>> _ = df.raffa.startlog().dropna(subset = [" bill_depth_mm" ]).raffa.endlog()
98- Removed 2/10 (20.00%) rows.
99+ Removed 2/10 (20.00%) rows. New shape: (8, 8).
99100Took: ...
100101
101102Operations that change values but not the shape need ``clone=True `` so the
@@ -110,7 +111,7 @@ The same accessor is available on a Series:
110111
111112>>> s = df[" bill_length_mm" ]
112113>>> _ = s.raffa.startlog().dropna().raffa.endlog(timeit = False )
113- Removed 2/10 (20.00%) values.
114+ Removed 2/10 (20.00%) values. New shape: (8,).
114115>>> _ = s.raffa.startlog(clone = True ).fillna(0 ).raffa.endlog(timeit = False )
115116Changed 2/10 (20.00%) values.
116117
@@ -264,17 +265,17 @@ Removing rows with nulls, filtering values, or selecting columns changes the
264265shape, which is logged:
265266
266267>>> _ = df.raffa.startlog().drop_nulls(subset = [" bill_depth_mm" ]).raffa.endlog(timeit = False )
267- Removed 2/10 (20.00%) rows.
268+ Removed 2/10 (20.00%) rows. New shape: (8, 8).
268269>>> _ = df.raffa.startlog().filter(pl.col(" species" )== " Adelie" ).raffa.endlog(timeit = False )
269- Removed 5/10 (50.00%) rows.
270+ Removed 5/10 (50.00%) rows. New shape: (5, 8).
270271>>> _ = df.raffa.startlog().select(pl.exclude([" bill_length_mm" , " bill_depth_mm" ])).raffa.endlog(timeit = False )
271- Removed 2/8 (25.00%) columns.
272+ Removed 2/8 (25.00%) columns. New shape: (10, 6).
272273
273274As with pandas, the default ``timeit=True `` appends the elapsed time on a second
274275line (the duration varies from run to run):
275276
276277>>> _ = df.raffa.startlog().filter(pl.col(" species" )== " Adelie" ).raffa.endlog()
277- Removed 5/10 (50.00%) rows.
278+ Removed 5/10 (50.00%) rows. New shape: (5, 8).
278279Took: ...
279280
280281Operations that change values but not the shape need ``clone=True ``:
0 commit comments