Skip to content

Commit 39fa180

Browse files
hsperrjreback
authored andcommitted
FIX: timeseries asfreq would drop the name of the index, closes #9854
1 parent 07257a0 commit 39fa180

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

doc/source/whatsnew/v0.16.1.txt

+24-17
Original file line numberDiff line numberDiff line change
@@ -96,49 +96,56 @@ Bug Fixes
9696
- Bug in json serialization when frame has length zero.(:issue:`9805`)
9797
- Bug in `read_csv` where missing trailing delimiters would cause segfault. (:issue:`5664`)
9898
- Bug in retaining index name on appending (:issue:`9862`)
99-
100-
10199
- Bug in ``scatter_matrix`` draws unexpected axis ticklabels (:issue:`5662`)
102-
103100
- Fixed bug in ``StataWriter`` resulting in changes to input ``DataFrame`` upon save (:issue:`9795`).
104-
105-
106101
- Bug in ``transform`` causing length mismatch when null entries were present and a fast aggregator was being used (:issue:`9697`)
107-
108102
- Bug in ``equals`` causing false negatives when block order differed (:issue:`9330`)
109-
110103
- Bug in ``read_sql_table`` error when reading postgres table with timezone (:issue:`7139`)
111-
112104
- Bug in ``DataFrame`` slicing may not retain metadata (:issue:`9776`)
113105
- Bug where ``TimdeltaIndex`` were not properly serialized in fixed ``HDFStore`` (:issue:`9635`)
114-
115106
- Bug in plotting continuously using ``secondary_y`` may not show legend properly. (:issue:`9610`, :issue:`9779`)
116-
117107
- Bug in ``DataFrame.plot(kind="hist")`` results in ``TypeError`` when ``DataFrame`` contains non-numeric columns (:issue:`9853`)
118108
- Bug where repeated plotting of ``DataFrame`` with a ``DatetimeIndex`` may raise ``TypeError`` (:issue:`9852`)
119-
120109
- Bug in ``Series.quantile`` on empty Series of type ``Datetime`` or ``Timedelta`` (:issue:`9675`)
121110
- Bug in ``where`` causing incorrect results when upcasting was required (:issue:`9731`)
122111
- Bug in ``FloatArrayFormatter`` where decision boundary for displaying "small" floats in decimal format is off by one order of magnitude for a given display.precision (:issue:`9764`)
123-
124112
- Fixed bug where ``DataFrame.plot()`` raised an error when both ``color`` and ``style`` keywords were passed and there was no color symbol in the style strings (:issue:`9671`)
125113
- Bug in ``read_csv`` and ``read_table`` when using ``skip_rows`` parameter if blank lines are present. (:issue:`9832`)
126-
127114
- Bug in ``read_csv()`` interprets ``index_col=True`` as ``1`` (:issue:`9798`)
128115
- Bug in index equality comparisons using ``==`` failing on Index/MultiIndex type incompatibility (:issue:`9875`)
129116
- Bug in which ``SparseDataFrame`` could not take `nan` as a column name (:issue:`8822`)
130-
131117
- Bug in ``Series.quantile`` on empty Series of type ``Datetime`` or ``Timedelta`` (:issue:`9675`)
132-
133118
- Bug in ``to_msgpack`` and ``read_msgpack`` zlib and blosc compression support (:issue:`9783`)
134-
135119
- Bug in unequal comparisons between a ``Series`` of dtype `"category"` and a scalar (e.g. ``Series(Categorical(list("abc"), categories=list("cba"), ordered=True)) > "b"``, which wouldn't use the order of the categories but use the lexicographical order. (:issue:`9848`)
136120

137121

122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
138135
- Bug in unequal comparisons between categorical data and a scalar, which was not in the categories (e.g. ``Series(Categorical(list("abc"), ordered=True)) > "d"``. This returned ``False`` for all elements, but now raises a ``TypeError``. Equality comparisons also now return ``False`` for ``==`` and ``True`` for ``!=``. (:issue:`9848`)
139136

140137
- Bug in ``MultiIndex.sortlevel()`` results in unicode level name breaks (:issue:`9875`)
141-
142138
- Bug in which ``groupby.transform`` incorrectly enforced output dtypes to match input dtypes. (:issue:`9807`)
143139

140+
141+
142+
143+
144+
145+
146+
147+
148+
149+
144150
- Bug where dividing a dataframe containing values of type ``Decimal`` by another ``Decimal`` would raise. (:issue:`9787`)
151+
- Bug where using DataFrames asfreq would remove the name of the index. (:issue:`9885`)

pandas/tseries/resample.py

+1
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ def asfreq(obj, freq, method=None, how=None, normalize=False):
480480
if len(obj.index) == 0:
481481
return obj.copy()
482482
dti = date_range(obj.index[0], obj.index[-1], freq=freq)
483+
dti.name = obj.index.name
483484
rs = obj.reindex(dti, method=method)
484485
if normalize:
485486
rs.index = rs.index.normalize()

pandas/tseries/tests/test_timeseries.py

+9
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,15 @@ def test_reindex_with_datetimes(self):
11311131
result = ts[list(ts.index[5:10])]
11321132
tm.assert_series_equal(result, expected)
11331133

1134+
def test_asfreq_keep_index_name(self):
1135+
# GH #9854
1136+
index_name = 'bar'
1137+
index = pd.date_range('20130101',periods=20,name=index_name)
1138+
df = pd.DataFrame([x for x in range(20)],columns=['foo'],index=index)
1139+
1140+
tm.assert_equal(index_name, df.index.name)
1141+
tm.assert_equal(index_name, df.asfreq('10D').index.name)
1142+
11341143
def test_promote_datetime_date(self):
11351144
rng = date_range('1/1/2000', periods=20)
11361145
ts = Series(np.random.randn(20), index=rng)

0 commit comments

Comments
 (0)