Skip to content

Panel.fillna() loses index names #3570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joeb1415 opened this issue May 10, 2013 · 2 comments
Closed

Panel.fillna() loses index names #3570

joeb1415 opened this issue May 10, 2013 · 2 comments
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

Comments

@joeb1415
Copy link

Panel.fillna() 

should accept

(axis= [0, 1, 2] or ['items', 'major_axis', 'minor_axis'])

as an argument.
Right now it essentially defaults to

(axis='major_axis')
@jreback
Copy link
Contributor

jreback commented May 10, 2013

the axis parameter only matters if your are ffill or bfill or interpolating on a particular axis

this is fixed in the series-inherit-ndframe (slated for 0.12), #3482 so will leave open for that

@joeb1415
Copy link
Author

Related:
Panel.fillna(method='bfill') loses the items name:

from pandas import Panel, date_range
from numpy.random import randn

p = Panel(randn(2, 5, 4), items=['Item1', 'Item2'], major_axis=date_range('1/1/2000', periods=5), minor_axis=['A', 'B', 'C', 'D'])

p.items.name = 'items'
p.major_axis.name = 'major'
p.minor_axis.name = 'minor'
print(p.items.name, p.major_axis.name, p.minor_axis.name)

p = p.fillna(method='bfill')
print(p.items.name, p.major_axis.name, p.minor_axis.name)

Returns:

('items', 'major', 'minor')
(None, 'major', 'minor')

Not so with method=None

p = p.fillna(0)
print(p.items.name, p.major_axis.name, p.minor_axis.name)

Returns:

('items', 'major', 'minor')
('items', 'major', 'minor')

Also not so with DataFrame.fillna() by any method:

from pandas import DataFrame

df = DataFrame(randn(2, 5), index=['Item1', 'Item2'], columns=date_range('1/1/2000', periods=5))

df.index.name = 'index'
df.columns.name = 'columns'
print(df.index.name, df.columns.name)

df = df.fillna(method='bfill')
print(df.index.name, df.columns.name)

Returns:

('index', 'columns')
('index', 'columns')

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 26, 2014
@jreback jreback modified the milestones: 0.16.0, 0.17.0 Jan 26, 2015
@jreback jreback modified the milestones: won't fix, Next Major Release Jul 11, 2017
@jreback jreback closed this as completed Jul 11, 2017
@TomAugspurger TomAugspurger modified the milestones: won't fix, No action Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants