BUG: SparseSeries constructor ignores input data name by sinhrks · Pull Request #10258 · pandas-dev/pandas (original) (raw)
When constructing Series from Series, name attribute is preserved otherwise specified.
import pandas as pd
s = pd.Series([1, 2, 3], name='a')
pd.Series(s)
#0 1
#1 2
#2 3
# Name: a, dtype: int64
pd.Series(s, name='x')
#0 1
#1 2
#2 3
# Name: x, dtype: int64
But SparseSeries doesn't preserve its name.
s = pd.SparseSeries([1, 2, 3], name='a')
pd.SparseSeries(s)
#0 1
#1 2
#2 3
# dtype: int64
# BlockIndex
# Block locations: array([0], dtype=int32)
# Block lengths: array([3], dtype=int32)