Skip to content
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

ENH: add to_series() method to Index and subclasses GH3275 #3280

Merged
1 commit merged into from Apr 9, 2013
Merged

ENH: add to_series() method to Index and subclasses GH3275 #3280

1 commit merged into from Apr 9, 2013

Conversation

ghost
Copy link

@ghost ghost commented Apr 8, 2013

#3275

In [10]: df=mkdf(10,5,r_idx_nlevels=2)

In [11]: df.index
Out[11]: 
MultiIndex
[R_l0_g0  R_l1_g0, R_l0_g1  R_l1_g1, R_l0_g2  R_l1_g2, R_l0_g3  R_l1_g3, R_l0_g4  R_l1_g4, R_l0_g5  R_l1_g5, R_l0_g6  R_l1_g6, R_l0_g7  R_l1_g7, R_l0_g8  R_l1_g8, R_l0_g9  R_l1_g9]

In [12]: # new method
    ...: df.index.to_series()
Out[12]: 
R0       R1     
R_l0_g0  R_l1_g0    (R_l0_g0, R_l1_g0)
R_l0_g1  R_l1_g1    (R_l0_g1, R_l1_g1)
R_l0_g2  R_l1_g2    (R_l0_g2, R_l1_g2)
R_l0_g3  R_l1_g3    (R_l0_g3, R_l1_g3)
R_l0_g4  R_l1_g4    (R_l0_g4, R_l1_g4)
R_l0_g5  R_l1_g5    (R_l0_g5, R_l1_g5)
R_l0_g6  R_l1_g6    (R_l0_g6, R_l1_g6)
R_l0_g7  R_l1_g7    (R_l0_g7, R_l1_g7)
R_l0_g8  R_l1_g8    (R_l0_g8, R_l1_g8)
R_l0_g9  R_l1_g9    (R_l0_g9, R_l1_g9)
dtype: object

In [13]: # so now this is possible
    ...: df[df.index.to_series().map(lambda x: "4" in x[0])]
Out[13]: 
C0              C_l0_g0 C_l0_g1 C_l0_g2 C_l0_g3 C_l0_g4
R0      R1                                             
R_l0_g4 R_l1_g4    R4C0    R4C1    R4C2    R4C3    R4C4

@ghost
Copy link
Author

ghost commented Apr 8, 2013

sandbox?

@jreback
Copy link
Contributor

jreback commented Apr 8, 2013

I say put in
it's mostly internal

@wesm
Copy link
Member

wesm commented Apr 9, 2013

Fine by me

ghost pushed a commit that referenced this pull request Apr 9, 2013
ENH: add to_series() method to Index and subclasses GH3275
@ghost ghost merged commit c8728e2 into pandas-dev:master Apr 9, 2013
@ghost
Copy link
Author

ghost commented Apr 9, 2013

Follow up on ml?

@wesm
Copy link
Member

wesm commented Apr 9, 2013

sure

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants