ENH: Add Series.str.casefold
State: closed

- [x] closes #25405  
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


Labels:
name: Enhancement
name: Strings
description: String extension data type and string data

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=h1) Report
> Merging [#25419](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/15d8178a3f81febe4d8ddb033d07e57359eb6167?src=pr&el=desc) will **decrease** coverage by `50.03%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25419/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master   #25419       +/-   ##
===========================================
- Coverage   91.73%    41.7%   -50.04%     
===========================================
  Files         173      173               
  Lines       52848    52850        +2     
===========================================
- Hits        48482    22040    -26442     
- Misses       4366    30810    +26444
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `?` | |
| #single | `41.7% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `33.19% <100%> (-65.4%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY2F0ZWdvcmljYWwucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/sas/sas\_constants.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfY29uc3RhbnRzLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/tseries/converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvY29udmVydGVyLnB5) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/io/formats/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvaHRtbC5weQ==) | `0% <0%> (-99.35%)` | :arrow_down: |
| [pandas/core/groupby/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9jYXRlZ29yaWNhbC5weQ==) | `0% <0%> (-95.46%)` | :arrow_down: |
| [pandas/io/sas/sas7bdat.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXM3YmRhdC5weQ==) | `0% <0%> (-91.17%)` | :arrow_down: |
| [pandas/io/sas/sas\_xport.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3Nhcy9zYXNfeHBvcnQucHk=) | `0% <0%> (-90.15%)` | :arrow_down: |
| ... and [132 more](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=footer). Last update [15d8178...6608c25](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=h1) Report
> Merging [#25419](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/85572de5e7bb188cfecc575ee56786406e79dc79?src=pr&el=desc) will **increase** coverage by `0.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25419/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25419      +/-   ##
==========================================
+ Coverage   91.74%   91.75%   +0.01%     
==========================================
  Files         173      173              
  Lines       52923    52955      +32     
==========================================
+ Hits        48554    48589      +35     
+ Misses       4369     4366       -3
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.32% <100%> (ø)` | :arrow_up: |
| #single | `41.72% <100%> (-0.02%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `98.59% <100%> (ø)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `96.85% <0%> (ø)` | :arrow_up: |
| [pandas/core/indexes/category.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9jYXRlZ29yeS5weQ==) | `98.61% <0%> (ø)` | :arrow_up: |
| [pandas/core/groupby/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9nZW5lcmljLnB5) | `87% <0%> (+0.01%)` | :arrow_up: |
| [pandas/io/json/json.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2pzb24vanNvbi5weQ==) | `93.22% <0%> (+0.08%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.66% <0%> (+0.09%)` | :arrow_up: |
| [pandas/core/groupby/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/25419/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9ncm91cGJ5LnB5) | `97.2% <0%> (+0.4%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=footer). Last update [85572de...22717a1](https://codecov.io/gh/pandas-dev/pandas/pull/25419?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

needs a mention in text.rst (also there is a list of functions ) and in the references 
and a whatsnew note
Thanks, @jreback I added it to `text.rst` as well as to `reference/series.rst`, I am not very sure which whatsnew note you refer to, I already added one in `0.25.0.rst`, please let me know if you want it to move somewhere else. 
Hello @charlesdong1991! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on February 28, 2019 at 19:59 Hours UTC
i change it a bit, now it looks like, do you prefer this? @WillAyd 
```
    Convert strings in the Series/Index to casefolded.
    .. versionadded:: 0.25.0
    Equivalent to :meth:`str.casefold`.

    Returns
    -------
    Series/Index of objects

    See Also
    --------
    Series.str.lower : Converts all characters to lowercase.
    Series.str.upper : Converts all characters to uppercase.
    Series.str.title : Converts first character of each word to uppercase and
        remaining to lowercase.
    Series.str.capitalize : Converts first character to uppercase and
        remaining to lowercase.
    Series.str.swapcase : Converts uppercase to lowercase and lowercase to
        uppercase.
    Series.str.casefold: Removes all case distinctions in the string.
```
lgtm. over to you @WillAyd 
@charlesdong1991 does that render correctly in HTML? Might need a blank line before versionadded
somehow, i still get this error when running `python make.py html --single pandas.Series.str.casefold`, is it because of `str.casefold` not in python2? @WillAyd  
```
Traceback (most recent call last):
  File "make.py", line 79, in _process_single_doc
    obj = getattr(obj, name)
AttributeError: type object 'StringMethods' has no attribute 'casefold'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make.py", line 339, in <module>
    sys.exit(main())
  File "make.py", line 334, in main
    args.verbosity, args.warnings_are_errors)
  File "make.py", line 46, in __init__
    single_doc = self._process_single_doc(single_doc)
  File "make.py", line 81, in _process_single_doc
    raise ImportError('Could not import {}'.format(single_doc))
ImportError: Could not import pandas.Series.str.casefold
```

And i was thinking to add a blank line in-between, however, for all other methods, there will be two blank lines, and i don't think it's good...
```
Convert strings in the Series/Index to lower.


Equivalent to :meth:`str.lower`.
```
Not sure the distinction you are trying to make with Python2 - are you actively developing with that?

Otherwise do the other methods produce something for you? I would think should work the same as the rest. As far as the blank lines go can just add a "\n" preceding the argument
i distinguish python 2 is because `str.casefold` is only valid in python3+ if i am not wrong.

It's quite wired that all other methods work fine, but this new added one...  and only this is valid only in python3, so i made a guess of where it might go wrong to get this error @WillAyd 

And i add \n to make new lines, thanks!
Looks like an issue in the make file which is causing it to pick up another pandas installation on your computer which obviously wouldn't have that attribute yet. I patched locally just to make sure so here's the doc:

<img width="791" alt="image" src="https://user-images.githubusercontent.com/609873/53599302-b79b9400-3b5b-11e9-8ddd-69ed032c9350.png">

lgtm
Thanks @charlesdong1991 nice work!