diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5b5b0d70f6b2a..8bd62faacdcad 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3974,7 +3974,7 @@ def asof(self, where, subset=None): nulls = self.isnull() if is_series else self[subset].isnull().any(1) if nulls.all(): if is_series: - return pd.Series(np.nan, index=where) + return pd.Series(np.nan, index=where, name=self.name) else: if is_list: return pd.DataFrame(np.nan, index=where, diff --git a/pandas/tests/series/test_asof.py b/pandas/tests/series/test_asof.py index 4b9a2cf160910..ee6ab15b8963a 100644 --- a/pandas/tests/series/test_asof.py +++ b/pandas/tests/series/test_asof.py @@ -169,3 +169,7 @@ def test_all_nans(self): date = date_range('1/1/1990', periods=N * 3, freq='25s')[0] result = Series(np.nan, index=rng).asof(date) assert isnull(result) + + # test name is propagated + result = Series(np.nan, index=[1, 2, 3, 4], name='test').asof([4, 5]) + self.assertEqual(result.name, 'test')