Skip to content

Commit af9a29b

Browse files
author
Carlos Souza
committed
Setting name of asof result when scalar input and all nan
1 parent b8f078a commit af9a29b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3980,7 +3980,7 @@ def asof(self, where, subset=None):
39803980
return pd.DataFrame(np.nan, index=where,
39813981
columns=self.columns)
39823982
else:
3983-
return pd.Series(np.nan, index=self.columns)
3983+
return pd.Series(np.nan, index=self.columns, name=where[0])
39843984

39853985
locs = self.index.asof_locs(where, ~(nulls.values))
39863986

pandas/tests/frame/test_asof.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ def test_all_nans(self):
104104
tm.assert_frame_equal(result, expected)
105105

106106
result = DataFrame(np.nan, index=[1, 2], columns=['A', 'B']).asof(3)
107-
expected = Series(np.nan, index=['A', 'B'])
107+
expected = Series(np.nan, index=['A', 'B'], name=3)
108108
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)