Skip to content

Conversation

@Garrett-R
Copy link
Contributor

closes #10445

I based this bugfix off how DataFrame handles the analogous situation ‒ being intialized to empty and then having a series added (cf. DataFrame._ensure_valid_index)

@jreback
Copy link
Contributor

jreback commented Jun 28, 2015

a more generic fix to this would be nice. IOW, put rename DataFrame._ensure_valid_index to _ensure_valid_axes and put in core/generic/NDFrame (and then DataFrame/Panel.__setitem__ can call it; Series doesn't need it).

then you can use the properties of the object to make sure that all of the not info_axis are valid

you iterate over the .axes (and skip the info_axis). For a frame this will yield (0), and a panel (1,2)

@jreback jreback added this to the 0.17.0 milestone Jun 28, 2015
@jreback jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Jun 28, 2015
@Garrett-R
Copy link
Contributor Author

Right, good call. I'll do that this week.

@Garrett-R
Copy link
Contributor Author

@jreback, so, there might an issue with merging the functionality of both DataFrame's _ensure_valid_index and Panel's _ensure_valid_major_minor_axes (which was part of this PR).

The DataFrame needs to case the incoming value to Series while the Panel one needs to cast to DataFrame.

At first I was worried about introducing a circle import, but in fact, I see generic.py is already circularly importing pandas.core.frame (through the import pandas as pd line). I guess I could special case the two options, but that would be kind of convoluted right? If I'm special casing for the 2 cases, I might as well keep the original two functions separate.

@jreback
Copy link
Contributor

jreback commented Jul 6, 2015

use _constructor_sliced that's what its there for. We rarely want to special case if at all possible.

@Garrett-R
Copy link
Contributor Author

Hmmm... I'm struggling with this one.

Attempt 2 to move this into NDFrame is no dice. You said above I could use the non-info axes to reindex and "For a frame this will yield (0), and a panel (1,2)". But actually, the axes I need to reindex is (1) for a DataFrame and (1,2) for a Panel...

Now that would not be hard to do by just doing a for loop and starting from 1 and incrementing up, but that seems like a convoluted way to tackle this.

Any ideas? Moving the functionality up to the base class might save some lines of code and is certainly clever, but keeping the reindexing in the derived classes wins in terms of simpleness. Am I missing an advantage of moving to the base class?

@jreback
Copy link
Contributor

jreback commented Aug 15, 2015

@Garrett-R can you update according to above comments.

@Garrett-R
Copy link
Contributor Author

@jreback, I was kind of struggling with moving the functionality up to the base class as per my last comment. I have time to keep trying (EDIT: meant to say: "I don't have"). If you think it's better to have the more general solution, we should probably close this PR and let the next person do it.

@jreback jreback modified the milestones: Next Major Release, 0.17.0 Aug 20, 2015
@jreback
Copy link
Contributor

jreback commented Aug 20, 2015

@Garrett-R will leave this open if you find the time to come back to it.

@jreback
Copy link
Contributor

jreback commented Oct 11, 2015

closing for now, if you want to update according to comments, pls reopen

@jreback jreback closed this Oct 11, 2015
@Garrett-R Garrett-R deleted the fix_10445 branch October 12, 2015 01:30
@Garrett-R
Copy link
Contributor Author

@jreback, I apologize for not responding. I probably won't end up getting back to it. Sorry and thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

2 participants