Skip to content

Commit 10147b0

Browse files
committed
move NaN handling to _get_indicies
1 parent 3f5c6d6 commit 10147b0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pandas/core/groupby/groupby.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -624,16 +624,18 @@ def get_converter(s):
624624
converter = get_converter(index_sample)
625625
names = (converter(name) for name in names)
626626

627-
return [self.indices.get(name, []) for name in names]
627+
return [
628+
self.indices.get(name, [])
629+
if not isna(name)
630+
else self.indices.get(pd.NaT, [])
631+
for name in names
632+
]
628633

629634
def _get_index(self, name):
630635
"""
631636
Safe get index, translate keys for datelike to underlying repr.
632637
"""
633-
if isna(name):
634-
return self._get_indices([pd.NaT])[0]
635-
else:
636-
return self._get_indices([name])[0]
638+
return self._get_indices([name])[0]
637639

638640
@cache_readonly
639641
def _selected_obj(self):

0 commit comments

Comments
 (0)