File tree 3 files changed +23
-2
lines changed
3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,26 @@ def time_category_size(self):
358
358
self .draws .groupby (self .cats ).size ()
359
359
360
360
361
+ class FillNA :
362
+ def setup (self ):
363
+ N = 100
364
+ self .df = DataFrame (
365
+ {"group" : [1 ] * N + [2 ] * N , "value" : [np .nan , 1.0 ] * N }
366
+ ).set_index ("group" )
367
+
368
+ def time_df_ffill (self ):
369
+ self .df .groupby ("group" ).fillna (method = "ffill" )
370
+
371
+ def time_df_bfill (self ):
372
+ self .df .groupby ("group" ).fillna (method = "bfill" )
373
+
374
+ def time_srs_ffill (self ):
375
+ self .df .groupby ("group" )["value" ].fillna (method = "ffill" )
376
+
377
+ def time_srs_bfill (self ):
378
+ self .df .groupby ("group" )["value" ].fillna (method = "bfill" )
379
+
380
+
361
381
class GroupByMethods :
362
382
363
383
param_names = ["dtype" , "method" , "application" ]
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ Bug fixes
29
29
~~~~~~~~~
30
30
- Bug causing ``groupby(...).sum() `` and similar to not preserve metadata (:issue: `29442 `)
31
31
- Bug in :meth: `Series.isin ` and :meth: `DataFrame.isin ` raising a ``ValueError `` when the target was read-only (:issue: `37174 `)
32
+ - Bug in :meth: `GroupBy.fillna ` that introduced a performance regression after 1.0.5 (:issue: `36757 `)
32
33
33
34
.. ---------------------------------------------------------------------------
34
35
Original file line number Diff line number Diff line change @@ -1202,12 +1202,12 @@ def reset_identity(values):
1202
1202
# when the ax has duplicates
1203
1203
# so we resort to this
1204
1204
# GH 14776, 30667
1205
- if ax .has_duplicates :
1205
+ if ax .has_duplicates and not result . axes [ self . axis ]. equals ( ax ) :
1206
1206
indexer , _ = result .index .get_indexer_non_unique (ax .values )
1207
1207
indexer = algorithms .unique1d (indexer )
1208
1208
result = result .take (indexer , axis = self .axis )
1209
1209
else :
1210
- result = result .reindex (ax , axis = self .axis )
1210
+ result = result .reindex (ax , axis = self .axis , copy = False )
1211
1211
1212
1212
elif self .group_keys :
1213
1213
You can’t perform that action at this time.
0 commit comments