5353 ordered = True ,
5454 )
5555 ),
56- "unordered" : Series (
57- Categorical (["x" , "y" , "x" ], ordered = False )
58- ),
56+ "unordered" : Series (Categorical (["x" , "y" , "x" ], ordered = False )),
5957 "num" : Series ([10 , 20 , 30 ]),
6058 "text" : Series (["u" , "v" , "w" ]),
6159 }
6563 # codes: a=0, c=2, b=1
6664 "ordered" : Series ([0 , 2 , 1 ], dtype = "int8" ),
6765 # unordered categorical should be untouched (still categorical)
68- "unordered" : Series (
69- Categorical (["x" , "y" , "x" ], ordered = False )
70- ),
66+ "unordered" : Series (Categorical (["x" , "y" , "x" ], ordered = False )),
7167 "num" : Series ([10 , 20 , 30 ]),
7268 "text" : Series (["u" , "v" , "w" ]),
7369 }
7470 ),
7571 id = "mixed-types-only-ordered-changes" ,
7672 ),
7773 pytest .param (
78- # 3 Duplicate column names: first 'dup' is ordered categorical, second 'dup' is non-categorical
74+ # 3 Duplicate column names: first 'dup' is ordered categorical,
75+ # second 'dup' is non-categorical
7976 DataFrame (
8077 {
8178 "dup" : Series (
9996 id = "duplicate-names-ordered-first" ,
10097 ),
10198 pytest .param (
102- # 4 Duplicate column names: first 'dup' is non-categorical, second 'dup' is ordered categorical, third 'dup' is ordered categorical
99+ # 4 Duplicate column names: first 'dup' is non-categorical,
100+ # second 'dup' is ordered categorical, third 'dup' is ordered categorical
103101 DataFrame (
104102 {
105103 "dup" : Series (["a" , "b" , "c" ]), # non-categorical (object)
121119 ),
122120 DataFrame (
123121 {
124- # First stays object; second turns into codes [0,1,NaN] and third changes into codes [0, 1, 2] as well
122+ # First stays object; second turns into codes [0, 1, NaN]
123+ # and third changes into codes [0, 1, 2]
125124 "dup" : Series (["a" , "b" , "c" ]),
126125 "dup" : Series ([0.0 , 1.0 , np .nan ]),
127126 "dup" : Series ([0 , 1 , 2 ], dtype = "int8" ),
@@ -135,4 +134,4 @@ def test_transform_ord_cat_cols_to_coded_cols(input_df, expected_df):
135134 out_df = transform_ord_cat_cols_to_coded_cols (input_df )
136135 assert list (out_df .columns ) == list (expected_df .columns )
137136 for i , col in enumerate (out_df .columns ):
138- tm .assert_series_equal (out_df .iloc [:, i ], expected_df .iloc [:, i ])
137+ tm .assert_series_equal (out_df .iloc [:, i ], expected_df .iloc [:, i ])
0 commit comments