Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

equivalent of gsub for Pandas Series / DataFrame

Tags:

python-3.x

r

What is the equivalent of R's sub / gsub functions for Python pandas' Series or DataFrame ?

For example, in R, my code is

schData<-gsub("/"," by ",schData,ignore.case=F)

What would be equivalent operation in Python when schData above is as follows:

>>> type(schData)
Out[N]: pandas.core.series.Series

for regular strings there is the re.sub function but that only seems to work with strings

like image 429
uday Avatar asked Feb 17 '14 16:02

uday


1 Answers

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html

That the type of thing you're looking for?

Python pandas equivalent for replace Has a few little examples.

PS: please include a reproducible example next time =)

like image 181
James Tobin Avatar answered Oct 30 '22 07:10

James Tobin