@@ -1190,18 +1190,17 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
11901190.. ipython :: python
11911191
11921192 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" )
11951195 arr = np.array([" foo" , " bar" , " baz" ], dtype = " object" )
11961196 pylist = [" foo" , " bar" , " baz" ]
11971197
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)
12021202
1203- # Series/Index with object dtype: infer string
1204- # dtype if all elements are strings
1203+ # Series/Index with object dtype: infer string dtype
12051204 assert cat_from_ser.categories.inferred_type == " string"
12061205 assert cat_from_idx.categories.inferred_type == " string"
12071206
@@ -1210,9 +1209,9 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
12101209 assert cat_from_list.categories.inferred_type == " string"
12111210
12121211 # 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)
12171216 assert cat_mixed_ser.categories.dtype == " object"
12181217 assert cat_mixed_idx.categories.dtype == " object"
0 commit comments