Mihirp
Mihirp

Reputation: 51

how does the method df.column.str.replace(' ','_') in pandas dataframe work?

I saw the type of column it is pandas.Index. But I don't understand, how can we use pandas.Index.str as str is a different class. I am proficient in Java so,I don't really understand .. how does this work in python? Can anyone please explain in detail. Thank you!

Upvotes: 0

Views: 52

Answers (1)

Anirudh Sridhar
Anirudh Sridhar

Reputation: 183

What you might be referring to is the string module. It has multiple string methods and classes.

However, pandas.Index is a class and it has the str method as it can be seen from here. This method allows vectorized string functions to be applied to values(index and series) in the dataframe.

Upvotes: 1

Related Questions