Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ebb78ee

Browse files
Update 07-常用函数.md
1 parent 254a750 commit ebb78ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎07-常用函数.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ df['close_matches'] = df['name'].apply(lambda x: difflib.get_close_matches(x, li
212212

213213
# 取出list中的字符串,相似度未达到阈值则为空
214214
df['close_matches'] = df['close_matches'].apply(lambda x: x[0] if len(x)>0 else np.nan)
215+
216+
# 计算相似度
217+
df['diff_score'] = df.apply(lambda x: difflib.SequenceMatcher(None, x.col1, x.col2).quick_ratio(), axis=1)
215218
```
216219

217220
<br/>
@@ -549,4 +552,4 @@ cut_df(df, 5)
549552

550553

551554

552-
| [**< <目录**](./README.md) | [**返回顶部 ↑**](#07-常用函数) |
555+
| [**< <目录**](./README.md) | [**返回顶部 ↑**](#07-常用函数) |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /