diff --git a/pandas/core/dtypes/concat.py b/pandas/core/dtypes/concat.py index 83c2668242129..a513d41b61c85 100644 --- a/pandas/core/dtypes/concat.py +++ b/pandas/core/dtypes/concat.py @@ -200,8 +200,6 @@ def union_categoricals( Examples -------- - >>> from pandas.api.types import union_categoricals - If you want to combine categoricals that do not necessarily have the same categories, `union_categoricals` will combine a list-like of categoricals. The new categories will be the union of the @@ -209,7 +207,7 @@ def union_categoricals( >>> a = pd.Categorical(["b", "c"]) >>> b = pd.Categorical(["a", "b"]) - >>> union_categoricals([a, b]) + >>> pd.api.types.union_categoricals([a, b]) ['b', 'c', 'a', 'b'] Categories (3, object): ['b', 'c', 'a'] @@ -217,7 +215,7 @@ def union_categoricals( in the `categories` of the data. If you want the categories to be lexsorted, use `sort_categories=True` argument. - >>> union_categoricals([a, b], sort_categories=True) + >>> pd.api.types.union_categoricals([a, b], sort_categories=True) ['b', 'c', 'a', 'b'] Categories (3, object): ['a', 'b', 'c'] @@ -227,7 +225,7 @@ def union_categoricals( >>> a = pd.Categorical(["a", "b"], ordered=True) >>> b = pd.Categorical(["a", "b", "a"], ordered=True) - >>> union_categoricals([a, b]) + >>> pd.api.types.union_categoricals([a, b]) ['a', 'b', 'a', 'b', 'a'] Categories (2, object): ['a' < 'b'] @@ -235,7 +233,7 @@ def union_categoricals( >>> a = pd.Categorical(["a", "b"], ordered=True) >>> b = pd.Categorical(["a", "b", "c"], ordered=True) - >>> union_categoricals([a, b]) + >>> pd.api.types.union_categoricals([a, b]) Traceback (most recent call last): ... TypeError: to union ordered Categoricals, all categories must be the same @@ -247,7 +245,7 @@ def union_categoricals( >>> a = pd.Categorical(["a", "b", "c"], ordered=True) >>> b = pd.Categorical(["c", "b", "a"], ordered=True) - >>> union_categoricals([a, b], ignore_order=True) + >>> pd.api.types.union_categoricals([a, b], ignore_order=True) ['a', 'b', 'c', 'c', 'b', 'a'] Categories (3, object): ['a', 'b', 'c'] @@ -257,7 +255,7 @@ def union_categoricals( >>> a = pd.Series(["b", "c"], dtype='category') >>> b = pd.Series(["a", "b"], dtype='category') - >>> union_categoricals([a, b]) + >>> pd.api.types.union_categoricals([a, b]) ['b', 'c', 'a', 'b'] Categories (3, object): ['b', 'c', 'a'] """ diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 4a50a3dabe5e7..fba51c83ad27a 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -3157,21 +3157,22 @@ class StataWriter117(StataWriter): Examples -------- - >>> from pandas.io.stata import StataWriter117 >>> data = pd.DataFrame([[1.0, 1, 'a']], columns=['a', 'b', 'c']) - >>> writer = StataWriter117('./data_file.dta', data) + >>> writer = pd.io.stata.StataWriter117('./data_file.dta', data) >>> writer.write_file() Directly write a zip file >>> compression = {"method": "zip", "archive_name": "data_file.dta"} - >>> writer = StataWriter117('./data_file.zip', data, compression=compression) + >>> writer = pd.io.stata.StataWriter117( + ... './data_file.zip', data, compression=compression + ... ) >>> writer.write_file() Or with long strings stored in strl format >>> data = pd.DataFrame([['A relatively long string'], [''], ['']], ... columns=['strls']) - >>> writer = StataWriter117('./data_file_with_long_strings.dta', data, - ... convert_strl=['strls']) + >>> writer = pd.io.stata.StataWriter117( + ... './data_file_with_long_strings.dta', data, convert_strl=['strls']) >>> writer.write_file() """