String.Replace python string replacement function () can use regular expressions, more elegant

Speaking afraid of people joke, I found today pythonin 字符串替换操作, that string.replace()can be used 正则表达式in.

Before, my code is worded as follows, clumsy:

image

Since the discovery of 正则表达式the also take effect, the code becomes elegantly simple:

image

Note: the above figure base_infois pandasin the dataframedata structure, the method described above can be used stringin the replacemethod.

Guess you like

Origin www.cnblogs.com/jjliu/p/11514226.html