首页 > 解决方案 > Delete sub string between two characters of Pandas Data frame with python

问题描述

I want to delete the character between "()" and "[]" of the column named 'RegionName'. The image of the DataFrame is given below.Screenshort of dataframe Please, tell me how can I do that!

标签: python-3.xpandasdata-sciencedata-cleaning

解决方案


if you want to remove () and [] after deleting the characters then you can do it with replace and regex

df.replace("[\(\[].*?[\)\]]", "",regex=True)

Input:

Auburn(Auburn University)[1]

Output:

Auburn

推荐阅读