'Why use df["column":].str as opposed to not

If I have a dataframe with a string column and I want to do some filtering, what's the difference between

df["string_column"].str.startswith(...)

and

df["string_column"].startswith(...)

Both work fine for me. I'm just curious of why we use .str



Solution 1:[1]

some methods are specific to string types only. such as contains(), lower(), replace()..

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Esad