我正在尝试使用python创建一个赔率匹配器,使用pandas比较游戏名称。我遇到的问题是如果数据不是100%匹配,那么它将无法识别游戏名称。
有没有一种有效的方法来匹配游戏名称?例如百分比匹配。模糊查找?我想不出一个可靠的方法来做到这一点,以尽量减少错误。有关如何通过Python实现这一点的任何想法?
a b c d e
EC Bahia v Salvador U20 2.3 EC Bahia v Salvador 2.3 NaN
EC Bahia v Salvador 2.3 EC Bahia v Salvador 2.3 Match You could get the first word before v and after but….
Bahai Samone v Salvator 2.3 EC Bahia v Salvador 2.3 Match However this causes problem when the string was Ec FAHI (different)
DF1
EW WE DA \
0 k k 2
1 EC Bahia Salvador U20 Clube Atletico Mineiro U20 2.3
2 Moreirense Rio Ave 1.62
3 EC Bahia Salvadoa U20 14
4 EC Bahia Salvador 4141
DD
0 https://www.b1
1 https://www.b1
2 https://www.b1
3 https://www.b1
4 https://www.b1
df2
AA AB AC AD \
0 Starting soon k k 3.15
1 In-Play FC Nitra U19 Z Michalovce U19 9.60
2 In-Play Sevilla U19 NK Maribor U19 NaN
3 In-Play Moreirense Rio Av 1.02
4 Starting in 13' EC Bahia Salvador 1.07
AE
0 https://www.be
1 https://www.be
2 https://www.be
3 https://www.be
4 https://www.be
所需:
AA AB AC AD \
0 Starting soon k k 3.15
1 Starting in 13' EC Bahia 9.60
1 In-Play Moreirense Rio Av 1.02
AE EW WE \
0 https://www.b1 k v k 2
1 https://www.b2 EC v Bahia 4141
3 https://www.b3 Moreirense v Rio Av 1.02
公式:
df1['EW'] = df1['EW'] + ' v ' + df1['EW']
df1['WE'] = df1['DA']
df1['DA'] = df1['DD']
df2['EW'] = df2['AB'] + ' v ' + df2['AC']
print('kk')
df3 = pd.merge(df2, df1, on='EW')
答案 0 :(得分:0)
您基本上要问"在Python中进行字符串比较的所有方法是什么?#34;这是一个巨大的问题。
一些真正基本的东西是做一些字符串格式化:
一些更先进的东西将是:
除此之外,你真的必须深入了解每一个恕我直言。