删除括号和逗号 [英] Removing parentheses and comma

查看:49
本文介绍了删除括号和逗号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将数据库中的数据导入 python 数据框.现在,我希望将数据用于进一步分析,但是,我需要在使用前对数据进行一些清理.目前,所需列的格式如下('2275.1',​​ '1950.4').我需要的输出应该类似于:2275.11950.4.有人可以帮忙吗

I'm importing Data from a database into python data frame. Now, I wish to use the data for further analysis, however, I need to do a little cleaning of the data before using. Currently, the required column is formatted like ('2275.1', '1950.4'). The output that I require should look like:2275.1 and 1950.4 exclusively. can someone please help

推荐答案

这是一种方法:

import re
x = "'('2275.1', '1950.4')'"
y = re.findall(r'\d+\.\d', x)
for i in y:
  print i

输出:

2275.1
1950.4

这篇关于删除括号和逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆