diff --git a/doc/_templates/pandas_footer.html b/doc/_templates/pandas_footer.html deleted file mode 100644 index 6d8caa4d6c741..0000000000000 --- a/doc/_templates/pandas_footer.html +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/doc/source/conf.py b/doc/source/conf.py index f222a228531ff..03e8127818f94 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -242,7 +242,7 @@ html_theme_options = { "external_links": [], - "footer_start": ["pandas_footer", "sphinx-version"], + "footer_start": ["copyright"], "github_url": "https://github.com/pandas-dev/pandas", "analytics": { "plausible_analytics_domain": "pandas.pydata.org", diff --git a/pandas/core/strings/accessor.py b/pandas/core/strings/accessor.py index 21e6e2efbe778..7cc88f6705066 100644 --- a/pandas/core/strings/accessor.py +++ b/pandas/core/strings/accessor.py @@ -527,6 +527,12 @@ def cat( alignment, use `.values` on any Series/Index/DataFrame in `others`. Returns + ------- + When concatenating with a Series or Index, pandas aligns on index labels + by default. This can produce NaN values if the indices do not match. + To get element-wise concatenation (the behavior before v0.23), + convert the object to numpy arrays with ``.values`` or ``.to_numpy()``. + ------- str, Series or Index If `others` is None, `str` is returned, otherwise a `Series/Index` @@ -613,6 +619,23 @@ def cat( 4 -e 2 -c dtype: str + Examples with Index + ------------------- + >>> idx = pd.Index(["a", "b", "c"]) + >>> ser = pd.Series(["x", "y", "z"]) + + # Default alignment behavior (indices match here) + >>> idx.str.cat(ser, join="left") + Index(['ax', 'by', 'cz'], dtype='object') + + # If indices do not match, result may contain NaN + >>> ser2 = pd.Series(["x", "y", "z"], index=[10, 11, 12]) + >>> idx.str.cat(ser2, join="left") + Index([nan, nan, nan], dtype='object') + + # Element-wise concatenation (old behavior) using .values + >>> idx.str.cat(ser.values) + Index(['ax', 'by', 'cz'], dtype='object') For more examples, see :ref:`here `. """