Skip to content

CLN: refactor core/index and tseries/index,period to have their format, to_native_types methods consistent #3193

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 2 commits into from
Mar 28, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Mar 27, 2013

  • ENH: add support for Period formatting (as a native type), add equals comparison method
    __eq__ et al added by others
  • TST: add period support to makeCustomDataFrame for testing purposes

@jreback
Copy link
Contributor Author

jreback commented Mar 28, 2013

@changhiskhan @y-p any problem with this?

@ghost
Copy link

ghost commented Mar 28, 2013

Index format_native_types does nan handling but corresponding Multindex code doesn't,
is that intentional?

@jreback
Copy link
Contributor Author

jreback commented Mar 28, 2013

not on purpose
I am not sure that we allow nan in a mi though? (it messes with the sortedness)
I am sure we can construct one though

@ghost
Copy link

ghost commented Mar 28, 2013

yeah, I've never seen one, but..

In [15]: df=mkdf(10,3,r_idx_nlevels=2)
    ...: df.index.values[0]= (np.nan, 'R_l1_g0')
    ...: pd.DataFrame(df.values,index=df.index.values)
    ...: 
Out[15]: 
                       0     1     2
(nan, R_l1_g0)      R0C0  R0C1  R0C2
(R_l0_g1, R_l1_g1)  R1C0  R1C1  R1C2
(R_l0_g2, R_l1_g2)  R2C0  R2C1  R2C2
(R_l0_g3, R_l1_g3)  R3C0  R3C1  R3C2
(R_l0_g4, R_l1_g4)  R4C0  R4C1  R4C2
(R_l0_g5, R_l1_g5)  R5C0  R5C1  R5C2
(R_l0_g6, R_l1_g6)  R6C0  R6C1  R6C2
(R_l0_g7, R_l1_g7)  R7C0  R7C1  R7C2
(R_l0_g8, R_l1_g8)  R8C0  R8C1  R8C2
(R_l0_g9, R_l1_g9)  R9C0  R9C1  R9C2

@jreback
Copy link
Contributor Author

jreback commented Mar 28, 2013

that is printing wrong then
should be NaN

I'll put a fix in - still should be illegal

@ghost
Copy link

ghost commented Mar 28, 2013

perhaps less synthetic:

In [25]: df=mkdf(10,3,data_gen_f=lambda r,c: np.nan if randint(0,2) > 0 else randint(0,100))
    ...: df
Out[25]: 
C0       C_l0_g0  C_l0_g1  C_l0_g2
R0                                
R_l0_g0      NaN      NaN       68
R_l0_g1       91       74      NaN
R_l0_g2        6      NaN       70
R_l0_g3       96      NaN      NaN
R_l0_g4      NaN      NaN       37
R_l0_g5      NaN       66       12
R_l0_g6      NaN      NaN      NaN
R_l0_g7      NaN       14       26
R_l0_g8      NaN      NaN      NaN
R_l0_g9      NaN       91      NaN

In [26]: df.set_index([df.columns[0],df.columns[1]])
Out[26]: 
                 C_l0_g2
C_l0_g0 C_l0_g1         
Na      Na            68
91      74           NaN
6       Na            70
96      Na           NaN
Na      Na            37
        66            12
        Na           NaN
        14            26
        Na           NaN
        91           NaN

jreback added 2 commits March 28, 2013 15:29
…ts and to_native_types be consistent

     in naming / operation
ENH: add support for Period formatting (as a native type)
TST: add period support to makeCustomDataFrame for testing purposes
jreback added a commit that referenced this pull request Mar 28, 2013
CLN: refactor core/index and tseries/index,period to have their format, to_native_types methods consistent
@jreback jreback merged commit 1a976d8 into pandas-dev:master Mar 28, 2013
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.

1 participant