Skip to content

BUG: multiple level unstack with nulls #9517

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

Merged
merged 1 commit into from
Mar 5, 2015

Conversation

behzadnouri
Copy link
Contributor

closes #9497

>>> mi
                        jim    joe
1st 2nd        3rd
1   2014-02-01 -1 days  100 -20.87
2   NaT        NaT      101   5.76
1   2014-02-03 1 days   102  -4.94
2   NaT        2 days   103  -0.79
1   2014-02-05 NaT      104 -12.51
2   2014-02-06 4 days   105  -9.89

>>> mi.unstack(['2nd', '3rd']).fillna('.')
           jim                                                     joe
2nd 2014-02-01  NaT 2014-02-03    NaT 2014-02-05 2014-02-06 2014-02-01   NaT 2014-02-03    NaT 2014-02-05 2014-02-06
3rd    -1 days  NaT     1 days 2 days        NaT     4 days    -1 days   NaT     1 days 2 days        NaT     4 days
1st
1          100    .        102      .        104          .     -20.87     .      -4.94      .     -12.51          .
2            .  101          .    103          .        105          .  5.76          .  -0.79          .      -9.89

@@ -1382,7 +1382,7 @@ def ngroups(self):
def recons_labels(self):
comp_ids, obs_ids, _ = self.group_info
labels = (ping.labels for ping in self.groupings)
return decons_obs_group_ids(comp_ids, obs_ids, self.shape, labels)
return decons_group_ids(comp_ids, obs_ids, self.shape, labels, True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a little easier to read if you include argument names when supplying boolean, e.g., use xnull=True

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Mar 5, 2015
jreback added a commit that referenced this pull request Mar 5, 2015
BUG: multiple level unstack with nulls
@jreback jreback merged commit f8fd05d into pandas-dev:master Mar 5, 2015
@jreback
Copy link
Contributor

jreback commented Mar 5, 2015

thanks @behzadnouri

@jreback jreback added this to the 0.16.0 milestone Mar 5, 2015
@behzadnouri behzadnouri deleted the unstack-multiple branch March 6, 2015 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: DataFrame.unstack() with two levels containing NaN
3 participants