python-3.x - 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!
解决方案
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
推荐阅读
- excel - 宏将值复制到范围的底部
- python - 使用 Python OS 模块:找出文件列表中的哪些文件已经在特定文件夹中
- protractor - 在量角器中比较 2 个相同的字符串失败,chai to.equal
- git - 通过 gitlab api 或 gitlab-cli 获取 gitlab 项目的 `id`
- r - 使用 r markdown knitr to word docx 的某些段落的较小字体
- c# - 无法为“IdentityUser”创建 DbSet,因为此类型未包含在上下文的模型中
- c# - ASP .NET Web 服务未定义
- android - 无法将导航器设置为 ACTION_OPEN_DOCUMENT 中的特定文件夹
- google-app-engine - 使用不记名令牌访问受 Google Cloud IAP 保护的资源会出现错误代码 13
- r - 如何用两个数据框r总结数据