1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
|
%global _empty_manifest_terminate_build 0
Name: python-pandas-dedupe
Version: 1.5.0
Release: 1
Summary: The Dedupe library made easy with Pandas.
License: MIT
URL: https://github.com/Lyonk71/pandas-dedupe
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/45/1f/f24ba1dbb5ff59f07dc8829c9d80c3ff9d1d4367f21d7d482243a92f3f4e/pandas_dedupe-1.5.0.tar.gz
BuildArch: noarch
Requires: python3-dedupe
Requires: python3-unidecode
Requires: python3-pandas
%description
# pandas-dedupe
The Dedupe library made easy with Pandas.
# Installation
```
pip install pandas-dedupe
```
# Video Tutorials
[Basic Deduplication](https://www.youtube.com/watch?v=lCFEzRaqoJA)
# Basic Usage
A training file and a settings file will be created while running Dedupe.
Keeping these files will eliminate the need to retrain your model in the future.
If you would like to retrain your model from scratch, just delete the settings and training files.
### Deduplication (dedupe_dataframe)
`dedupe_dataframe` is for deduplication when you have data that can contain multiple records that can all refer to the same entity
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'middle_initial'])
#send output to csv
df_final.to_csv('deduplication_output.csv')
```
### Gazetteer deduplication (gazetteer_dataframe)
`gazetteer_dataframe` is for matching a messy dataset against a 'canonical dataset' (i.e. the gazette)
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df_clean = pd.read_csv('gazette.csv')
df_messy = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.gazetteer_dataframe(df_clean, df_messy, 'fullname', canonicalize=True)
#send output to csv
df_final.to_csv('gazetteer_deduplication_output.csv')
```
### Matching / Record Linkage
Use identical field names when linking dataframes.
Record linkage should only be used on dataframes that have been deduplicated.
```python
import pandas as pd
import pandas_dedupe
#load dataframes
dfa = pd.read_csv('file_a.csv')
dfb = pd.read_csv('file_b.csv')
#initiate matching
df_final = pandas_dedupe.link_dataframes(dfa, dfb, ['field_1', 'field_2', 'field_3', 'field_4'])
#send output to csv
df_final.to_csv('linkage_output.csv')
```
# Advanced Usage
### Canonicalize Fields
The canonicalize parameter will standardize names in a given cluster. Original fields are also kept.
```python
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'payment_type'], canonicalize=True)
```
### Update Threshold (dedupe_dataframe and gazetteer_dataframe only)
Group records into clusters only if the cophenetic similarity of the cluster is greater than
the threshold.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], threshold=.7)
```
### Update Existing Model (dedupe_dataframe and gazetteer_dataframe only)
If `True`, it allows a user to update the existing model.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], update_model=True)
```
### Recall Weight & Sample Size
The `dedupe_dataframe()` function has two optional parameters specifying `recall_weight` and `sample_size`:
- **recall_weight** - Ranges from 0 to 2. When set to 2, we are saying we care twice as much
about recall than we do about precision.
- **sample_size** - Specifies the sample size used for training as a float from 0 to 1.
By default it is 30% (0.3) of our data.
### Specifying Types
If you'd like to specify dates, spatial data, etc, do so here. The structure must be like so:
`('field', 'type', 'additional_parameter)`. the `additional_parameter` section can be omitted.
The default type is `String`.
See the full list of types [below](#Types).
```python
# Price Example
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', ('salary', 'Price')])
# has missing Example
pandas_dedupe.link_dataframes(df,['SSN', ('bio_pgraph', 'Text'), ('salary', 'Price', 'has missing')])
# crf Example
pandas_dedupe.dedupe_dataframe(df,[('first_name', 'String', 'crf'), 'last_name', (m_initial, 'Exact')])
```
# Types
Dedupe supports a variety of datatypes; a full list with documentation can be found [here.](https://docs.dedupe.io/en/latest/Variable-definition.html#)
pandas-dedupe officially supports the following datatypes:
- **String** - Standard string comparison using string distance metric. This is the default type.
- **Text** - Comparison for sentences or paragraphs of text. Uses cosine similarity metric.
- **Price** - For comparing positive, non zero numerical values.
- **DateTime** - For comparing dates.
- **LatLong** - (39.990334, 70.012) will not match to (40.01, 69.98) using a string distance
metric, even though the points are in a geographically similar location. The LatLong type resolves
this by calculating the haversine distance between compared coordinates. LatLong requires
the field to be in the format (Lat, Long). The value can be a string, a tuple containing two
strings, a tuple containing two floats, or a tuple containing two integers. If the format
is not able to be processed, you will get a traceback.
- **Exact** - Tests whether fields are an exact match.
- **Exists** - Sometimes, the presence or absence of data can be useful in predicting a match.
The Exists type tests for whether both, one, or neither of fields are null.
Additional supported parameters are:
- **has missing** - Can be used if one of your data fields contains null values
- **crf** - Use conditional random fields for comparisons rather than distance metric. May be more
accurate in some cases, but runs much slower. Works with String and ShortString types.
# Contributors
[Tyler Marrs](http://tylermarrs.com/) - Refactored code, added docstrings, added `threshold` parameter
[Tawni Marrs](https://github.com/tawnimarrs) - refactored code, added docstrings
[ieriii](https://github.com/ieriii) - Added `update_model` parameter, updated codebase to use `Dedupe 2.0`, added support for multiprocessing, added `gazetteer_dataframe`.
[Daniel Marczin](https://github.com/dim5) - Extensive updates to documentation to enhance readability.
# Credits
Many thanks to folks at [DataMade](https://datamade.us/) for making the the [Dedupe library](https://github.com/dedupeio/dedupe) publicly available. People interested in a code-free implementation of the dedupe library can find a link here: [Dedupe.io](https://dedupe.io/pricing/).
%package -n python3-pandas-dedupe
Summary: The Dedupe library made easy with Pandas.
Provides: python-pandas-dedupe
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-pandas-dedupe
# pandas-dedupe
The Dedupe library made easy with Pandas.
# Installation
```
pip install pandas-dedupe
```
# Video Tutorials
[Basic Deduplication](https://www.youtube.com/watch?v=lCFEzRaqoJA)
# Basic Usage
A training file and a settings file will be created while running Dedupe.
Keeping these files will eliminate the need to retrain your model in the future.
If you would like to retrain your model from scratch, just delete the settings and training files.
### Deduplication (dedupe_dataframe)
`dedupe_dataframe` is for deduplication when you have data that can contain multiple records that can all refer to the same entity
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'middle_initial'])
#send output to csv
df_final.to_csv('deduplication_output.csv')
```
### Gazetteer deduplication (gazetteer_dataframe)
`gazetteer_dataframe` is for matching a messy dataset against a 'canonical dataset' (i.e. the gazette)
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df_clean = pd.read_csv('gazette.csv')
df_messy = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.gazetteer_dataframe(df_clean, df_messy, 'fullname', canonicalize=True)
#send output to csv
df_final.to_csv('gazetteer_deduplication_output.csv')
```
### Matching / Record Linkage
Use identical field names when linking dataframes.
Record linkage should only be used on dataframes that have been deduplicated.
```python
import pandas as pd
import pandas_dedupe
#load dataframes
dfa = pd.read_csv('file_a.csv')
dfb = pd.read_csv('file_b.csv')
#initiate matching
df_final = pandas_dedupe.link_dataframes(dfa, dfb, ['field_1', 'field_2', 'field_3', 'field_4'])
#send output to csv
df_final.to_csv('linkage_output.csv')
```
# Advanced Usage
### Canonicalize Fields
The canonicalize parameter will standardize names in a given cluster. Original fields are also kept.
```python
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'payment_type'], canonicalize=True)
```
### Update Threshold (dedupe_dataframe and gazetteer_dataframe only)
Group records into clusters only if the cophenetic similarity of the cluster is greater than
the threshold.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], threshold=.7)
```
### Update Existing Model (dedupe_dataframe and gazetteer_dataframe only)
If `True`, it allows a user to update the existing model.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], update_model=True)
```
### Recall Weight & Sample Size
The `dedupe_dataframe()` function has two optional parameters specifying `recall_weight` and `sample_size`:
- **recall_weight** - Ranges from 0 to 2. When set to 2, we are saying we care twice as much
about recall than we do about precision.
- **sample_size** - Specifies the sample size used for training as a float from 0 to 1.
By default it is 30% (0.3) of our data.
### Specifying Types
If you'd like to specify dates, spatial data, etc, do so here. The structure must be like so:
`('field', 'type', 'additional_parameter)`. the `additional_parameter` section can be omitted.
The default type is `String`.
See the full list of types [below](#Types).
```python
# Price Example
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', ('salary', 'Price')])
# has missing Example
pandas_dedupe.link_dataframes(df,['SSN', ('bio_pgraph', 'Text'), ('salary', 'Price', 'has missing')])
# crf Example
pandas_dedupe.dedupe_dataframe(df,[('first_name', 'String', 'crf'), 'last_name', (m_initial, 'Exact')])
```
# Types
Dedupe supports a variety of datatypes; a full list with documentation can be found [here.](https://docs.dedupe.io/en/latest/Variable-definition.html#)
pandas-dedupe officially supports the following datatypes:
- **String** - Standard string comparison using string distance metric. This is the default type.
- **Text** - Comparison for sentences or paragraphs of text. Uses cosine similarity metric.
- **Price** - For comparing positive, non zero numerical values.
- **DateTime** - For comparing dates.
- **LatLong** - (39.990334, 70.012) will not match to (40.01, 69.98) using a string distance
metric, even though the points are in a geographically similar location. The LatLong type resolves
this by calculating the haversine distance between compared coordinates. LatLong requires
the field to be in the format (Lat, Long). The value can be a string, a tuple containing two
strings, a tuple containing two floats, or a tuple containing two integers. If the format
is not able to be processed, you will get a traceback.
- **Exact** - Tests whether fields are an exact match.
- **Exists** - Sometimes, the presence or absence of data can be useful in predicting a match.
The Exists type tests for whether both, one, or neither of fields are null.
Additional supported parameters are:
- **has missing** - Can be used if one of your data fields contains null values
- **crf** - Use conditional random fields for comparisons rather than distance metric. May be more
accurate in some cases, but runs much slower. Works with String and ShortString types.
# Contributors
[Tyler Marrs](http://tylermarrs.com/) - Refactored code, added docstrings, added `threshold` parameter
[Tawni Marrs](https://github.com/tawnimarrs) - refactored code, added docstrings
[ieriii](https://github.com/ieriii) - Added `update_model` parameter, updated codebase to use `Dedupe 2.0`, added support for multiprocessing, added `gazetteer_dataframe`.
[Daniel Marczin](https://github.com/dim5) - Extensive updates to documentation to enhance readability.
# Credits
Many thanks to folks at [DataMade](https://datamade.us/) for making the the [Dedupe library](https://github.com/dedupeio/dedupe) publicly available. People interested in a code-free implementation of the dedupe library can find a link here: [Dedupe.io](https://dedupe.io/pricing/).
%package help
Summary: Development documents and examples for pandas-dedupe
Provides: python3-pandas-dedupe-doc
%description help
# pandas-dedupe
The Dedupe library made easy with Pandas.
# Installation
```
pip install pandas-dedupe
```
# Video Tutorials
[Basic Deduplication](https://www.youtube.com/watch?v=lCFEzRaqoJA)
# Basic Usage
A training file and a settings file will be created while running Dedupe.
Keeping these files will eliminate the need to retrain your model in the future.
If you would like to retrain your model from scratch, just delete the settings and training files.
### Deduplication (dedupe_dataframe)
`dedupe_dataframe` is for deduplication when you have data that can contain multiple records that can all refer to the same entity
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'middle_initial'])
#send output to csv
df_final.to_csv('deduplication_output.csv')
```
### Gazetteer deduplication (gazetteer_dataframe)
`gazetteer_dataframe` is for matching a messy dataset against a 'canonical dataset' (i.e. the gazette)
```python
import pandas as pd
import pandas_dedupe
#load dataframe
df_clean = pd.read_csv('gazette.csv')
df_messy = pd.read_csv('test_names.csv')
#initiate deduplication
df_final = pandas_dedupe.gazetteer_dataframe(df_clean, df_messy, 'fullname', canonicalize=True)
#send output to csv
df_final.to_csv('gazetteer_deduplication_output.csv')
```
### Matching / Record Linkage
Use identical field names when linking dataframes.
Record linkage should only be used on dataframes that have been deduplicated.
```python
import pandas as pd
import pandas_dedupe
#load dataframes
dfa = pd.read_csv('file_a.csv')
dfb = pd.read_csv('file_b.csv')
#initiate matching
df_final = pandas_dedupe.link_dataframes(dfa, dfb, ['field_1', 'field_2', 'field_3', 'field_4'])
#send output to csv
df_final.to_csv('linkage_output.csv')
```
# Advanced Usage
### Canonicalize Fields
The canonicalize parameter will standardize names in a given cluster. Original fields are also kept.
```python
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', 'payment_type'], canonicalize=True)
```
### Update Threshold (dedupe_dataframe and gazetteer_dataframe only)
Group records into clusters only if the cophenetic similarity of the cluster is greater than
the threshold.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], threshold=.7)
```
### Update Existing Model (dedupe_dataframe and gazetteer_dataframe only)
If `True`, it allows a user to update the existing model.
```python
pandas_dedupe.dedupe_dataframe(df, ['first_name', 'last_name'], update_model=True)
```
### Recall Weight & Sample Size
The `dedupe_dataframe()` function has two optional parameters specifying `recall_weight` and `sample_size`:
- **recall_weight** - Ranges from 0 to 2. When set to 2, we are saying we care twice as much
about recall than we do about precision.
- **sample_size** - Specifies the sample size used for training as a float from 0 to 1.
By default it is 30% (0.3) of our data.
### Specifying Types
If you'd like to specify dates, spatial data, etc, do so here. The structure must be like so:
`('field', 'type', 'additional_parameter)`. the `additional_parameter` section can be omitted.
The default type is `String`.
See the full list of types [below](#Types).
```python
# Price Example
pandas_dedupe.dedupe_dataframe(df,['first_name', 'last_name', ('salary', 'Price')])
# has missing Example
pandas_dedupe.link_dataframes(df,['SSN', ('bio_pgraph', 'Text'), ('salary', 'Price', 'has missing')])
# crf Example
pandas_dedupe.dedupe_dataframe(df,[('first_name', 'String', 'crf'), 'last_name', (m_initial, 'Exact')])
```
# Types
Dedupe supports a variety of datatypes; a full list with documentation can be found [here.](https://docs.dedupe.io/en/latest/Variable-definition.html#)
pandas-dedupe officially supports the following datatypes:
- **String** - Standard string comparison using string distance metric. This is the default type.
- **Text** - Comparison for sentences or paragraphs of text. Uses cosine similarity metric.
- **Price** - For comparing positive, non zero numerical values.
- **DateTime** - For comparing dates.
- **LatLong** - (39.990334, 70.012) will not match to (40.01, 69.98) using a string distance
metric, even though the points are in a geographically similar location. The LatLong type resolves
this by calculating the haversine distance between compared coordinates. LatLong requires
the field to be in the format (Lat, Long). The value can be a string, a tuple containing two
strings, a tuple containing two floats, or a tuple containing two integers. If the format
is not able to be processed, you will get a traceback.
- **Exact** - Tests whether fields are an exact match.
- **Exists** - Sometimes, the presence or absence of data can be useful in predicting a match.
The Exists type tests for whether both, one, or neither of fields are null.
Additional supported parameters are:
- **has missing** - Can be used if one of your data fields contains null values
- **crf** - Use conditional random fields for comparisons rather than distance metric. May be more
accurate in some cases, but runs much slower. Works with String and ShortString types.
# Contributors
[Tyler Marrs](http://tylermarrs.com/) - Refactored code, added docstrings, added `threshold` parameter
[Tawni Marrs](https://github.com/tawnimarrs) - refactored code, added docstrings
[ieriii](https://github.com/ieriii) - Added `update_model` parameter, updated codebase to use `Dedupe 2.0`, added support for multiprocessing, added `gazetteer_dataframe`.
[Daniel Marczin](https://github.com/dim5) - Extensive updates to documentation to enhance readability.
# Credits
Many thanks to folks at [DataMade](https://datamade.us/) for making the the [Dedupe library](https://github.com/dedupeio/dedupe) publicly available. People interested in a code-free implementation of the dedupe library can find a link here: [Dedupe.io](https://dedupe.io/pricing/).
%prep
%autosetup -n pandas-dedupe-1.5.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-pandas-dedupe -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Sun Apr 23 2023 Python_Bot <Python_Bot@openeuler.org> - 1.5.0-1
- Package Spec generated
|