有没有办法让不区分大小写的正则表达式替换为Pandas数据帧?我宁愿保持工作矢量化,而不必在字符串级别创建一个循环,re.sub是apparently limited。)
(当我尝试将re.sub与数据帧一起使用时,编译器会抱怨它需要字符串。)
fables['animal_names'] = re.sub(r"(^|\s+|,)hippo(,|\s+|$)"," Hippopotamus ", fables['animal_names'])
TypeError:期望的字符串或类似字节的对象