Skip to content

Commit a080b9b

Browse files
author
Carlos Souza
committed
Making scalar input return in a Series
1 parent 04b7306 commit a080b9b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pandas/core/generic.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -3976,7 +3976,11 @@ def asof(self, where, subset=None):
39763976
if is_series:
39773977
return pd.Series(np.nan, index=where)
39783978
else:
3979-
return pd.DataFrame(np.nan, index=where, columns=self.columns)
3979+
if is_list:
3980+
return pd.DataFrame(np.nan, index=where,
3981+
columns=self.columns)
3982+
else:
3983+
return pd.Series(np.nan, index=[where])
39803984

39813985
locs = self.index.asof_locs(where, ~(nulls.values))
39823986

pandas/tests/frame/test_asof.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ def test_all_nans(self):
101101
# testing scalar input
102102
date = date_range('1/1/1990', periods=self.N * 3, freq='25s')[0]
103103
result = DataFrame(np.nan, index=self.rng, columns=['A']).asof(date)
104-
expected = DataFrame(np.nan, index=[date], columns=['A'])
105-
tm.assert_frame_equal(result, expected)
104+
expected = Series(np.nan, index=[date])
105+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)