File size: 39,721 Bytes
47cc2c7
 
 
 
 
 
 
 
003953a
 
 
 
47cc2c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80e8771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
003953a
80e8771
 
 
 
 
003953a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47cc2c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import combinations\n",
    "import numpy as np\n",
    "import os\n",
    "import pandas as pd"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Load data from file into a pandas df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "File 'hr.csv' loaded successfully.                                                                                      \n",
      "Found 311 rows, 36 columns\n"
     ]
    }
   ],
   "source": [
    "DATADIR=\"data/\"\n",
    "FILENAME=None\n",
    "\n",
    "while FILENAME is None:\n",
    "    \n",
    "    file_candidate = input(\"Enter file name:\")\n",
    "    if file_candidate == \"\": break\n",
    "    \n",
    "    try:\n",
    "        print(f\"Assesing file '{file_candidate}'...\".ljust(120), end=\"\\r\")\n",
    "        file_path = DATADIR + file_candidate\n",
    "        extension = file_candidate.split(\".\")[-1] \n",
    "        match extension:\n",
    "            case \"csv\":\n",
    "                df = pd.read_csv(file_path)\n",
    "            case \"json\":\n",
    "                df = pd.read_json(file_path)\n",
    "            case \"xlsx\":\n",
    "                df = pd.read_excel(file_path)\n",
    "            case _:\n",
    "                print(f\"Error: Invalid extension '{extension}'\")\n",
    "                continue\n",
    "        print(f\"File '{file_candidate}' loaded successfully.\")\n",
    "        rows, columns = df.shape\n",
    "        print(f\"Found {rows} rows, {columns} columns\")\n",
    "        FILENAME = file_candidate\n",
    "    except FileNotFoundError:\n",
    "        print(f\"Error: '{file_candidate}' doesn't exist in {os.getcwd()}/{DATADIR}\")\n",
    "    except Exception as error:\n",
    "        print(f\"Error: Unable to read file '{file_candidate}' ({str(type(error))}: {error})\".ljust(120))"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Clean data to remove duplicates and rows with missing values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "DROP_MISSING = False\n",
    "REMOVE_DUPLICATES = True\n",
    "\n",
    "df = df.dropna(how=\"any\" if DROP_MISSING else \"all\")\n",
    "if REMOVE_DUPLICATES: df = df.drop_duplicates()"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Anonymize data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
      "/var/folders/7t/d7j4tqwj061958h80lldp0dh0000gn/T/ipykernel_19712/355045301.py:38: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Employee_Name</th>\n",
       "      <th>EmpID</th>\n",
       "      <th>MarriedID</th>\n",
       "      <th>MaritalStatusID</th>\n",
       "      <th>GenderID</th>\n",
       "      <th>EmpStatusID</th>\n",
       "      <th>DeptID</th>\n",
       "      <th>PerfScoreID</th>\n",
       "      <th>FromDiversityJobFairID</th>\n",
       "      <th>Salary</th>\n",
       "      <th>...</th>\n",
       "      <th>ManagerName</th>\n",
       "      <th>ManagerID</th>\n",
       "      <th>RecruitmentSource</th>\n",
       "      <th>PerformanceScore</th>\n",
       "      <th>EngagementSurvey</th>\n",
       "      <th>EmpSatisfaction</th>\n",
       "      <th>SpecialProjectsCount</th>\n",
       "      <th>LastPerformanceReview_Date</th>\n",
       "      <th>DaysLateLast30</th>\n",
       "      <th>Absences</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>None</td>\n",
       "      <td>(10022, 10042)</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>(62065, 63381)</td>\n",
       "      <td>...</td>\n",
       "      <td>Michael Albert</td>\n",
       "      <td>22.0</td>\n",
       "      <td>LinkedIn</td>\n",
       "      <td>Exceeds</td>\n",
       "      <td>(4.52, 4.68)</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1/17/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>None</td>\n",
       "      <td>(10064, 10084)</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(92328, 104437)</td>\n",
       "      <td>...</td>\n",
       "      <td>Simon Roup</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Indeed</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(4.9, 5.0)</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>None</td>\n",
       "      <td>0</td>\n",
       "      <td>17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>None</td>\n",
       "      <td>(10190, 10210)</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(64816, 66825)</td>\n",
       "      <td>...</td>\n",
       "      <td>Kissy Sullivan</td>\n",
       "      <td>20.0</td>\n",
       "      <td>LinkedIn</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(2.9, 3.18)</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>None</td>\n",
       "      <td>(10085, 10105)</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(64816, 66825)</td>\n",
       "      <td>...</td>\n",
       "      <td>Elijiah Gray</td>\n",
       "      <td>16.0</td>\n",
       "      <td>Indeed</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(4.7, 4.88)</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1/3/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>None</td>\n",
       "      <td>(10064, 10084)</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(47837, 51259)</td>\n",
       "      <td>...</td>\n",
       "      <td>Webster Butler</td>\n",
       "      <td>39.0</td>\n",
       "      <td>Google Search</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(5.0, 5.0)</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2/1/2016</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>306</th>\n",
       "      <td>None</td>\n",
       "      <td>(10127, 10147)</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(64816, 66825)</td>\n",
       "      <td>...</td>\n",
       "      <td>Kissy Sullivan</td>\n",
       "      <td>20.0</td>\n",
       "      <td>LinkedIn</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(3.99, 4.1)</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>2/28/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>307</th>\n",
       "      <td>None</td>\n",
       "      <td>None</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>5</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>(47837, 51259)</td>\n",
       "      <td>...</td>\n",
       "      <td>Brannon Miller</td>\n",
       "      <td>12.0</td>\n",
       "      <td>Google Search</td>\n",
       "      <td>PIP</td>\n",
       "      <td>(3.19, 3.5)</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>308</th>\n",
       "      <td>None</td>\n",
       "      <td>(10001, 10021)</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>None</td>\n",
       "      <td>...</td>\n",
       "      <td>Janet King</td>\n",
       "      <td>2.0</td>\n",
       "      <td>Employee Referral</td>\n",
       "      <td>Exceeds</td>\n",
       "      <td>(4.52, 4.68)</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>2/21/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>309</th>\n",
       "      <td>None</td>\n",
       "      <td>(10043, 10063)</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>3</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(77692, 90100)</td>\n",
       "      <td>...</td>\n",
       "      <td>Simon Roup</td>\n",
       "      <td>4.0</td>\n",
       "      <td>Employee Referral</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(5.0, 5.0)</td>\n",
       "      <td>3</td>\n",
       "      <td>5</td>\n",
       "      <td>2/1/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>310</th>\n",
       "      <td>None</td>\n",
       "      <td>(10252, 10271)</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>(45046, 47750)</td>\n",
       "      <td>...</td>\n",
       "      <td>David Stanley</td>\n",
       "      <td>14.0</td>\n",
       "      <td>LinkedIn</td>\n",
       "      <td>Fully Meets</td>\n",
       "      <td>(4.5, 4.52)</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>1/30/2019</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>311 rows × 36 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    Employee_Name           EmpID  MarriedID  MaritalStatusID  GenderID  \\\n",
       "0            None  (10022, 10042)          0                0         1   \n",
       "1            None  (10064, 10084)          1                1         1   \n",
       "2            None  (10190, 10210)          1                1         0   \n",
       "3            None  (10085, 10105)          1                1         0   \n",
       "4            None  (10064, 10084)          0                2         0   \n",
       "..            ...             ...        ...              ...       ...   \n",
       "306          None  (10127, 10147)          0                0         1   \n",
       "307          None            None          0                0         0   \n",
       "308          None  (10001, 10021)          0                0         0   \n",
       "309          None  (10043, 10063)          0                0         0   \n",
       "310          None  (10252, 10271)          0                4         0   \n",
       "\n",
       "     EmpStatusID  DeptID  PerfScoreID  FromDiversityJobFairID  \\\n",
       "0              1       5            4                       0   \n",
       "1              5       3            3                       0   \n",
       "2              5       5            3                       0   \n",
       "3              1       5            3                       0   \n",
       "4              5       5            3                       0   \n",
       "..           ...     ...          ...                     ...   \n",
       "306            1       5            3                       0   \n",
       "307            5       5            1                       0   \n",
       "308            1       3            4                       0   \n",
       "309            1       3            3                       0   \n",
       "310            1       5            3                       0   \n",
       "\n",
       "              Salary  ...     ManagerName  ManagerID  RecruitmentSource  \\\n",
       "0     (62065, 63381)  ...  Michael Albert       22.0           LinkedIn   \n",
       "1    (92328, 104437)  ...      Simon Roup        4.0             Indeed   \n",
       "2     (64816, 66825)  ...  Kissy Sullivan       20.0           LinkedIn   \n",
       "3     (64816, 66825)  ...    Elijiah Gray       16.0             Indeed   \n",
       "4     (47837, 51259)  ...  Webster Butler       39.0      Google Search   \n",
       "..               ...  ...             ...        ...                ...   \n",
       "306   (64816, 66825)  ...  Kissy Sullivan       20.0           LinkedIn   \n",
       "307   (47837, 51259)  ...  Brannon Miller       12.0      Google Search   \n",
       "308             None  ...      Janet King        2.0  Employee Referral   \n",
       "309   (77692, 90100)  ...      Simon Roup        4.0  Employee Referral   \n",
       "310   (45046, 47750)  ...   David Stanley       14.0           LinkedIn   \n",
       "\n",
       "    PerformanceScore EngagementSurvey EmpSatisfaction SpecialProjectsCount  \\\n",
       "0            Exceeds     (4.52, 4.68)               5                    0   \n",
       "1        Fully Meets       (4.9, 5.0)               3                    6   \n",
       "2        Fully Meets      (2.9, 3.18)               3                    0   \n",
       "3        Fully Meets      (4.7, 4.88)               5                    0   \n",
       "4        Fully Meets       (5.0, 5.0)               4                    0   \n",
       "..               ...              ...             ...                  ...   \n",
       "306      Fully Meets      (3.99, 4.1)               4                    0   \n",
       "307              PIP      (3.19, 3.5)               2                    0   \n",
       "308          Exceeds     (4.52, 4.68)               5                    6   \n",
       "309      Fully Meets       (5.0, 5.0)               3                    5   \n",
       "310      Fully Meets      (4.5, 4.52)               5                    0   \n",
       "\n",
       "    LastPerformanceReview_Date DaysLateLast30 Absences  \n",
       "0                    1/17/2019              0        1  \n",
       "1                         None              0       17  \n",
       "2                         None              0        3  \n",
       "3                     1/3/2019              0       15  \n",
       "4                     2/1/2016              0        2  \n",
       "..                         ...            ...      ...  \n",
       "306                  2/28/2019              0       13  \n",
       "307                       None              5        4  \n",
       "308                  2/21/2019              0       16  \n",
       "309                   2/1/2019              0       11  \n",
       "310                  1/30/2019              0        2  \n",
       "\n",
       "[311 rows x 36 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "K = 2\n",
    "MAX_CATEGORICAL_SIZE = 50\n",
    "BIN_SIZE = 20\n",
    "SENSITIVITY_MINIMUM = 2\n",
    "\n",
    "def column_combinations(df, k):\n",
    "    return list(combinations(df.columns, k))\n",
    "\n",
    "def k_redact(df, k):\n",
    "    kwise_combinations = column_combinations(df, k) \n",
    "    \n",
    "    for columns in kwise_combinations:\n",
    "        df_search = df.loc[:, columns]\n",
    "        sensitive_data = [\n",
    "            (columns, key)\n",
    "            for key, value\n",
    "            in df_search.value_counts().to_dict().items()\n",
    "            if value == 1\n",
    "            ]\n",
    "        if not sensitive_data: continue\n",
    "        for columns, values in sensitive_data:\n",
    "            for column, value in zip(columns, values):\n",
    "                df_search = df_search.loc[df[column] == value]\n",
    "                if df_search.shape[0] == 1:\n",
    "                    for column in columns:\n",
    "                        df_search[column] = None\n",
    "    \n",
    "    return df\n",
    "\n",
    "def sensitive_values(series, sensitivity_minimum):\n",
    "    return {key\n",
    "        for key, value\n",
    "        in series.value_counts().to_dict().items()\n",
    "        if value < sensitivity_minimum\n",
    "        }\n",
    "\n",
    "def drop_sensitive(series, sensitivity_minimum):\n",
    "    series.loc[series.isin(sensitive_values(series, sensitivity_minimum))] = None\n",
    "\n",
    "def bin_numeric(df, to_process, bin_size, sensitivity_minimum):\n",
    "    processed = set()\n",
    "    rows, _ = df.shape\n",
    "    num_bins = rows//bin_size\n",
    "    for column_name in to_process:\n",
    "        column = df[column_name]\n",
    "        if column.dtype.kind not in \"biufc\": continue\n",
    "        array = sorted(np.array(column))\n",
    "        array_min, array_max = array[0], array[-1]\n",
    "        splits = [array_min] + list(np.array_split(array, num_bins)) + [array_max]\n",
    "        bins = [\n",
    "            (np.min(split), np.max(split))\n",
    "            for split\n",
    "            in (splits[i] for i in range(num_bins))\n",
    "            ]\n",
    "        result = [None] * rows\n",
    "        for bin_min, bin_max in bins:\n",
    "            for i, value in enumerate(column):\n",
    "                if bin_min <= value <= bin_max:\n",
    "                    result[i] = (bin_min, bin_max)\n",
    "        df[column_name] = result\n",
    "        drop_sensitive(df[column_name], sensitivity_minimum)\n",
    "        processed.add(column_name)\n",
    "    return df, to_process - processed\n",
    "\n",
    "def find_categorical(df, to_process, max_categorical_size, sensitivity_minimum):\n",
    "    processed = set()\n",
    "    for column_name in to_process:\n",
    "        column = df[column_name]\n",
    "        if column.nunique() <= max_categorical_size:\n",
    "            drop_sensitive(column, sensitivity_minimum)\n",
    "            processed.add(column_name)\n",
    "    return df, to_process - processed\n",
    "\n",
    "def redact(df, to_process, sensitivity_minimum):\n",
    "    processed = set()\n",
    "    for column_name in to_process:\n",
    "        column = df[column_name]\n",
    "        \n",
    "        is_object = column.dtype == object\n",
    "        if not is_object: continue\n",
    "\n",
    "        # Check if any unique values exist, and redact them\n",
    "        drop_sensitive(column, sensitivity_minimum)\n",
    "        processed.add(column_name)\n",
    "\n",
    "    return df, to_process - processed\n",
    "\n",
    "def anonymize(df, max_categorical_size, bin_size, sensitivity_minimum):\n",
    "    to_process = set(df.columns)\n",
    "    df, to_process = redact(df, to_process, sensitivity_minimum)\n",
    "    df, to_process = find_categorical(df, to_process, max_categorical_size, sensitivity_minimum)\n",
    "    df, to_process = bin_numeric(df, to_process, bin_size, sensitivity_minimum)\n",
    "    return df, to_process\n",
    "\n",
    "def data_anonymizer(df, k, max_categorical_size, bin_size, sensitivity_minimum):\n",
    "    start_dtypes = df.dtypes.to_dict()\n",
    "    df, unprocessed = anonymize(df, max_categorical_size, bin_size, sensitivity_minimum)\n",
    "    df = k_redact(df, k)\n",
    "    end_dtypes = df.dtypes.to_dict()\n",
    "\n",
    "    # Type correction\n",
    "    for column in df.columns:\n",
    "        start_type, end_type  = start_dtypes[column], end_dtypes[column]\n",
    "        if start_type == end_type: continue\n",
    "        if start_type.kind == \"i\" and end_type.kind == \"f\":\n",
    "            df[column] = df[column].astype(\"Int64\")\n",
    "\n",
    "    return df, unprocessed\n",
    "\n",
    "df, unprocessed_columns = data_anonymizer(df, K, MAX_CATEGORICAL_SIZE, BIN_SIZE, SENSITIVITY_MINIMUM)\n",
    "if unprocessed_columns: print(f\"Failed to process columns '{unprocessed_columns}'\")\n",
    "df"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}