Use the columns monthly_spend_k, transactions, avg_balance_k and online_pct, scaled with StandardScaler (call the result X). Fit KMeans(n_clusters=4, n_init=10, random_state=0) on X.
A new customer spends ₹50k a month over 60 transactions, keeps ₹140k on average and does 80% of payments online. Scale them with the same scaler, predict the group, and store how many existing customers are in that group in result.
import io
import pandas as pd
cards = pd.read_csv(io.StringIO("""customer_id,monthly_spend_k,transactions,avg_balance_k,online_pct
701,42.9,59,173,69
702,26.6,29,12,54
703,50.7,56,166,78
704,19.1,19,17,41
705,6.7,10,38,8
706,15.3,34,9,53
707,108.3,28,487,29
708,53.8,51,178,74
709,18.9,39,12,45
710,87.9,36,353,44
711,46,65,120,72
712,77.4,32,483,43
713,32.3,52,179,75
714,18.2,33,13,41
715,90.5,28,387,26
716,55.1,55,151,57
717,24.7,37,11,70
718,10.6,18,34,23
719,101.9,16,453,25
720,29.2,49,180,71
721,17.9,33,9,42
722,7.8,11,34,22
723,33.5,64,154,84
724,9.8,15,27,37
725,16.9,25,26,44
726,97.9,20,319,42
727,6.8,13,51,14
728,20.3,27,13,42
729,10.3,16,34,16
730,32.8,53,126,81
731,8.1,11,33,29
732,27.3,23,12,42
733,45.1,52,81,70
734,19.1,35,12,64
735,52,55,148,76
736,54.9,52,135,78
737,7.2,12,53,17
738,10.3,12,53,23
739,15.2,28,19,44
740,47.9,63,128,75
741,84,18,354,25
742,7.5,10,45,26
743,8.7,13,62,38
744,75.6,26,413,53
745,19.5,28,19,48
746,43,44,134,81
747,18,39,14,48
748,12,4,52,15
749,16.6,27,15,56
750,5.4,13,52,26
751,81.9,23,427,29
752,9.1,12,56,15
753,20.8,28,21,45
754,49.3,55,150,73
755,103.5,21,409,24
756,8.9,11,31,15
757,16.9,33,17,38
758,17.5,28,29,26
759,14.1,25,20,35
760,83.1,34,342,47
761,19.7,37,11,31
762,24.1,38,12,41
763,21.2,41,21,39
764,22.6,31,17,45
765,46.5,55,117,67
766,56.2,55,180,84
767,7.7,9,40,30
768,9.1,15,45,5
769,43.7,53,186,67
770,22,37,15,52
771,8.1,10,41,24
772,10,8,38,20
773,17.8,30,9,45
774,6,8,38,9
775,46.8,56,159,68
776,22.5,31,11,43
777,90.3,23,429,37
778,8.4,17,20,33
779,26.9,31,13,39
780,40.6,50,185,71
781,33.2,46,125,84
782,49.9,47,132,73
783,13.5,26,20,49
784,60.9,33,135,86
785,45.3,45,184,79
786,105.3,19,466,33
787,7.7,12,32,36
788,21.1,32,20,32
789,14.2,26,0,20
790,55.4,31,451,23
791,17.2,29,5,39
792,22.3,20,15,56
793,26.8,28,4,40
794,95.5,32,378,51
795,93.6,27,485,20
796,109.6,12,432,45
797,45.3,43,156,77
798,7.8,9,39,20
799,43.2,51,114,87
800,7.3,11,29,15
801,20.8,28,16,37
802,49,47,159,86
803,25.8,31,20,49
804,10.3,14,44,14
805,45.8,52,161,79
806,20.2,32,14,23
807,50.4,48,195,68
808,20.3,22,13,44
809,93.1,29,372,11
810,47.9,52,200,67
811,86.3,23,416,52
812,43.4,54,135,78
813,9.7,10,53,26
814,39.3,58,210,86
815,10.3,14,54,15
816,89.8,26,351,31
817,5.4,20,32,20
818,14.1,34,13,50
819,10.9,12,38,36
820,86.1,19,372,36
821,100.4,26,453,37
822,38.6,57,118,68
823,8.8,15,45,23
824,9,10,37,28
825,18.6,26,16,40
826,39.2,52,127,92
827,67.6,21,462,28
828,7.6,7,54,18
829,81.9,25,440,33
830,23.3,19,21,23
831,21.4,23,13,47
832,20.2,32,20,56
833,86.7,32,509,15
834,7.2,8,48,22
835,12.4,11,30,36
836,16.4,39,19,69
837,54.3,59,152,68
838,39.8,40,174,85
839,10.1,11,37,12
840,4,11,54,23
841,86.4,22,418,32
842,10.2,16,21,19
843,5.9,7,46,36
844,20.5,31,22,38
845,49.1,50,177,76
846,88.4,29,476,10
847,17.3,25,12,53
848,5.9,7,44,16
849,79.6,28,437,16
850,7.3,14,37,18
851,37.5,63,131,81
852,23.4,36,22,52
853,97.4,20,454,38
854,6.8,9,50,7
855,27.7,34,19,51
856,7.2,10,62,26
857,77.3,29,465,22
858,4.2,8,49,15
859,45.1,49,161,69
860,90.2,27,389,13
861,90.3,21,339,21
862,47.7,57,169,77
863,82.4,29,372,36
864,7.6,13,33,14
865,92.5,23,436,30
866,8.8,10,45,14
867,78.6,18,411,35
868,76.3,31,395,35
869,10.7,18,60,28
870,5,13,26,8
871,14.3,36,17,49
872,35.5,57,152,71
873,17.1,28,14,46
874,12.1,13,30,31
875,47.2,50,127,75
876,8.4,13,41,28
877,82,25,381,39
878,18.9,27,20,43
879,44.1,52,180,67
880,15.3,29,12,47
881,47.7,49,145,60
882,81.8,30,290,36
883,12.7,29,2,50
884,22.2,31,19,64
885,8.6,22,41,28
886,17,30,13,47
887,50.4,80,143,63
888,18,31,7,47
889,95.9,25,451,14
890,111.8,19,319,23"""))Store your final answer in a variable named result.
Each hint gives a little more help. Try on your own first.
Run your code to see the output here.