@@ -1190,18 +1190,17 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
1190
1190
.. ipython :: python
1191
1191
1192
1192
with pd.option_context(" future.infer_string" , True ):
1193
- ser = Series([" foo" , " bar" , " baz" ], dtype = " object" )
1194
- idx = Index([" foo" , " bar" , " baz" ], dtype = " object" )
1193
+ ser = pd. Series([" foo" , " bar" , " baz" ], dtype = " object" )
1194
+ idx = pd. Index([" foo" , " bar" , " baz" ], dtype = " object" )
1195
1195
arr = np.array([" foo" , " bar" , " baz" ], dtype = " object" )
1196
1196
pylist = [" foo" , " bar" , " baz" ]
1197
1197
1198
- cat_from_ser = Categorical(ser)
1199
- cat_from_idx = Categorical(idx)
1200
- cat_from_arr = Categorical(arr)
1201
- cat_from_list = Categorical(pylist)
1198
+ cat_from_ser = pd. Categorical(ser)
1199
+ cat_from_idx = pd. Categorical(idx)
1200
+ cat_from_arr = pd. Categorical(arr)
1201
+ cat_from_list = pd. Categorical(pylist)
1202
1202
1203
- # Series/Index with object dtype: infer string
1204
- # dtype if all elements are strings
1203
+ # Series/Index with object dtype: infer string dtype
1205
1204
assert cat_from_ser.categories.inferred_type == " string"
1206
1205
assert cat_from_idx.categories.inferred_type == " string"
1207
1206
@@ -1210,9 +1209,9 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
1210
1209
assert cat_from_list.categories.inferred_type == " string"
1211
1210
1212
1211
# Mixed types: preserve object dtype
1213
- ser_mixed = Series([" foo" , 1 , None ], dtype = " object" )
1214
- idx_mixed = Index([" foo" , 1 , None ], dtype = " object" )
1215
- cat_mixed_ser = Categorical(ser_mixed)
1216
- cat_mixed_idx = Categorical(idx_mixed)
1212
+ ser_mixed = pd. Series([" foo" , 1 , None ], dtype = " object" )
1213
+ idx_mixed = pd. Index([" foo" , 1 , None ], dtype = " object" )
1214
+ cat_mixed_ser = pd. Categorical(ser_mixed)
1215
+ cat_mixed_idx = pd. Categorical(idx_mixed)
1217
1216
assert cat_mixed_ser.categories.dtype == " object"
1218
1217
assert cat_mixed_idx.categories.dtype == " object"
0 commit comments