我有一大段文本在某些句号后缺少空格。然而文本也包含十进制数字。
这是到目前为止我使用正则表达式解决问题的方法(我使用的是 python):
re.sub(r"(?!\d\.\d)(?!\. )\.", '. ', my_string)
但第一批逃亡团似乎不起作用。它仍然匹配十进制数字中的句点。
以下是示例文本,以确保任何潜在的解决方案都有效:
this is a.match
this should also match.1234
and this should 123.match
this should NOT match. Has space after period
this also should NOT match 1.23
Run Code Online (Sandbox Code Playgroud) 我有两个相同列的dfA和dfB数据帧.我希望只获取dataframe dfB中不存在于dataframe dfA中的记录.
要清楚,我不想在dfA中获取不在dfB中的记录.
我设法破解了一起使用它的东西,但代码不容易理解,而且扩展不是非常pythonic.
我正在寻找一个更优雅的解决方案,也许使用pandas join/merge/append但是无法使其工作.
我想要的例子:
dfA:
Date Category Price
1 2013-11-24 Coat 22.1
2 2013-11-24 Shirt 8.7
3 2013-11-01 Socks 9 <<< Only present in this df
dfB:
Date Category Price
1 2013-11-24 Coat 22.1
2 2013-11-24 Shirt 8.7
3 2013-11-24 Helmet 2.1 <<< Only present in this df
4 2013-11-24 Pants 10.7 <<< Only present in this df
Result:
Date Category Price
1 2013-11-24 Helmet 2.1
2 2013-11-24 Pants 10.7
Run Code Online (Sandbox Code Playgroud)