<filename>covid19/xxx_check_data.py<gh_stars>0
from collections import Counter

def digit_hist(data,lo=None,hi=None):
	digit_cnt = Counter()
	cnt = 0
	for x in data:
		digits = str(x)[lo:hi]
		for d in digits:
			digit_cnt[int(d)] += 1
			cnt += 1
	out = []
	for i in range(10):
		x = digit_cnt[i]
		out.append(x)
	return out,cnt

def pprint_digit_hist(data,lo=None,hi=None):
	hist,cnt = digit_hist(data,lo,hi)
	for d,c in enumerate(hist):
		f = c/cnt
		#s = int(f*100) * "*"
		s = c * "*"
		print(f"{d} -> {f:.03f}\t{c:5d}\t{s}")

test_data = [123,123,5342,1242134,12,341,23,12,31,23]

# view-source:https://www.worldometers.info/coronavirus/country/us/
total = {
	'poland' : [1,5,6,11,17,22,31,51,68,104,125,177,238,287,355,425,536,634,749,901,1051,1221,1389,1638,1862,2055,2311]
	,'us' : [12,10,29,29,28,48,51,54,54,57,60,65,85,106,138,200,289,401,504,663,949,1248,1581,2126,2664,3484,4434,6127,8940,13464,18965,23720,33000,42930,53697,66790,82272,99909,118127,136349,155141,177226]
	,'germany' : [16,18,26,48,74,79,130,165,203,262,545,670,800,1040,1224,1565,1966,2745,3675,4599,5813,7272,9367,12327,15320,19848,22364,24873,29056,32991,37323,43938,50871,57695,62435,66885,71808]
	,'spain' : [2,3,9,13,25,33,58,84,120,165,228,282,401,525,674,1231,1695,2277,3146,5232,6391,7988,9942,11826,14769,18077,21571,25496,28768,35136,42058,49515,57786,65719,73235,80110,87956]
	,'italy' : [3,4,21,79,157,229,323,470,655,889,1128,1701,2036,2502,3089,3858,4636,5883,7375,9172,10149,12462,15113,17660,21157,24747,27980,31506,35713,41035,47021,53578,59138,63927,69176,74386,80589,86498,92472,97689,101739,105792]
	,'france' : [12,14,18,38,57,100,130,191,212,285,423,653,949,1209,1412,1784,2281,2876,3661,4499,5423,6633,7730,9134,10995,12612,14459,16018,19856,22304,25233,29155,32964,37575,40174,44550,52128]
	,'canada' : [8,9,9,10,11,11,12,14,15,20,24,27,30,34,37,54,60,66,77,95,110,142,198,252,341,441,598,727,873,1087,1328,1470,2091,2792,3409,4043,4757,5655,6320,7448,8612]
	,'china' : [571,830,1287,1975,2744,4515,5974,7711,9692,11791,14380,17205,20440,24324,28018,31161,34546,37198,40171,42638,44653,58761,63851,66492,68500,70548,72436,74185,74576,75465,76288,76936,77150,77658,78064,78497,78824,79251,79824,80026,80151,80270,80409,80552,80651,80695,80735,80754,80778,80793,80813,80824,80844,80860,80881,80894,80928,80967,81008,81054,81093,81171,81218,81285,81340,81394,81439,81439,81518,81554]
	,'iran' : [2,5,18,29,43,61,95,139,245,388,593,978,1501,2336,2922,3513,4747,5823,6566,7161,8042,9000,10075,11364,12729,13938,14991,16169,17361,18407,19644,20610,21638,23049,24811,27017,29406,32332,35408,38309,41495,44605]
	,'uk' : [9,13,13,13,13,16,20,23,36,39,51,87,116,164,209,278,321,383,460,590,798,1140,1391,1543,1950,2626,3269,3983,5018,5683,6650,8077,9529,11658,14543,17089,19522,22141,25150]
	,'belgium' : [1,2,8,15,23,50,109,169,200,239,267,314,399,559,689,886,1058,1243,1486,1795,2257,2815,3401,3743,4269,4937,6235,7284,9134,10836,11899,12775]
}

new = {
	'poland' : [4,1,5,6,5,9,20,17,36,21,52,61,49,68,70,111,98,115,152,150,170,168,249,224,193,256]
	,'us' : [20,0,0,18,4,3,0,3,5,7,25,24,34,63,98,116,106,163,290,307,329,553,587,843,983,1748,2853,4582,5588,4825,9400,10189,11075,13355,17224,18691,19452,19913,20297,24742]
	,'germany' : [2,8,22,26,5,51,35,38,59,283,125,130,240,184,341,401,779,930,924,1214,1459,2095,2960,2993,4528,2516,2509,4183,3935,4332,6615,6933,6824,4740,4450,4923]
	,'spain' : [1,6,4,12,8,25,26,36,45,63,54,119,124,149,557,464,582,869,2086,1159,1597,1954,1884,2943,3308,3494,3925,3272,6368,6922,7457,8271,7933,7516,6875,7846]
	,'italy' : [1,17,58,78,72,94,147,185,234,239,573,335,466,587,769,778,1247,1492,1797,977,2313,2651,2547,3497,3590,3233,3526,4207,5322,5986,6557,5560,4789,5249,5210,6203,5909,5974,5217,4050,4053]
	,'france' : [2,4,20,19,43,30,61,21,73,138,230,296,260,203,372,497,595,785,838,924,1210,1097,1404,1861,1617,1847,1559,3838,2448,2929,3922,3809,4611,2599,4376,7578]
	,'canada' : [1,0,1,1,0,1,2,1,5,4,3,3,4,3,17,6,6,11,18,15,32,56,54,89,100,157,129,146,214,241,142,621,701,617,634,714,898,665,1128,1164]
	,'china' : [259,457,688,769,1771,1459,1737,1981,2099,2589,2825,3235,3884,3694,3143,3385,2652,2973,2467,2015,14108,5090,2641,2008,2048,1888,1749,391,889,823,648,214,508,406,433,327,427,573,202,125,119,139,143,99,44,40,19,24,15,20,11,20,16,21,13,34,39,41,46,39,78,47,67,55,54,45,0,79,36]
	,'iran' : [3,13,11,14,18,34,44,106,143,205,385,523,835,586,591,1234,1076,743,595,881,958,1075,1289,1365,1209,1053,1178,1192,1046,1237,966,1028,1411,1762,2206,2389,2926,3076,2901,3186,3110]
	,'uk' : [4,0,0,0,3,4,3,13,3,12,36,29,48,45,69,43,62,77,130,208,342,251,152,407,676,643,714,1035,665,967,1427,1452,2129,2885,2546,2433,2619,3009]
	,'belgium' : [1,6,7,8,27,59,60,31,39,28,47,85,160,130,197,172,185,243,309,462,558,586,342,526,668,1298,1049,1850,1702,1063,876]
}

for c in new:
	print(f'{c.upper()}:')
	pprint_digit_hist(new[c],1,None)
	print()

<filename>covid19/xxx_check_data.py<gh_stars>0
from collections import Counter

def digit_hist(data,lo=None,hi=None):
	digit_cnt = Counter()
	cnt = 0
	for x in data:
		digits = str(x)[lo:hi]
		for d in digits:
			digit_cnt[int(d)] += 1
			cnt += 1
	out = []
	for i in range(10):
		x = digit_cnt[i]
		out.append(x)
	return out,cnt

def pprint_digit_hist(data,lo=None,hi=None):
	hist,cnt = digit_hist(data,lo,hi)
	for d,c in enumerate(hist):
		f = c/cnt
		#s = int(f*100) * "*"
		s = c * "*"
		print(f"{d} -> {f:.03f}\t{c:5d}\t{s}")

test_data = [123,123,5342,1242134,12,341,23,12,31,23]

# view-source:https://www.worldometers.info/coronavirus/country/us/
total = {
	'poland' : [1,5,6,11,17,22,31,51,68,104,125,177,238,287,355,425,536,634,749,901,1051,1221,1389,1638,1862,2055,2311]
	,'us' : [12,10,29,29,28,48,51,54,54,57,60,65,85,106,138,200,289,401,504,663,949,1248,1581,2126,2664,3484,4434,6127,8940,13464,18965,23720,33000,42930,53697,66790,82272,99909,118127,136349,155141,177226]
	,'germany' : [16,18,26,48,74,79,130,165,203,262,545,670,800,1040,1224,1565,1966,2745,3675,4599,5813,7272,9367,12327,15320,19848,22364,24873,29056,32991,37323,43938,50871,57695,62435,66885,71808]
	,'spain' : [2,3,9,13,25,33,58,84,120,165,228,282,401,525,674,1231,1695,2277,3146,5232,6391,7988,9942,11826,14769,18077,21571,25496,28768,35136,42058,49515,57786,65719,73235,80110,87956]
	,'italy' : [3,4,21,79,157,229,323,470,655,889,1128,1701,2036,2502,3089,3858,4636,5883,7375,9172,10149,12462,15113,17660,21157,24747,27980,31506,35713,41035,47021,53578,59138,63927,69176,74386,80589,86498,92472,97689,101739,105792]
	,'france' : [12,14,18,38,57,100,130,191,212,285,423,653,949,1209,1412,1784,2281,2876,3661,4499,5423,6633,7730,9134,10995,12612,14459,16018,19856,22304,25233,29155,32964,37575,40174,44550,52128]
	,'canada' : [8,9,9,10,11,11,12,14,15,20,24,27,30,34,37,54,60,66,77,95,110,142,198,252,341,441,598,727,873,1087,1328,1470,2091,2792,3409,4043,4757,5655,6320,7448,8612]
	,'china' : [571,830,1287,1975,2744,4515,5974,7711,9692,11791,14380,17205,20440,24324,28018,31161,34546,37198,40171,42638,44653,58761,63851,66492,68500,70548,72436,74185,74576,75465,76288,76936,77150,77658,78064,78497,78824,79251,79824,80026,80151,80270,80409,80552,80651,80695,80735,80754,80778,80793,80813,80824,80844,80860,80881,80894,80928,80967,81008,81054,81093,81171,81218,81285,81340,81394,81439,81439,81518,81554]
	,'iran' : [2,5,18,29,43,61,95,139,245,388,593,978,1501,2336,2922,3513,4747,5823,6566,7161,8042,9000,10075,11364,12729,13938,14991,16169,17361,18407,19644,20610,21638,23049,24811,27017,29406,32332,35408,38309,41495,44605]
	,'uk' : [9,13,13,13,13,16,20,23,36,39,51,87,116,164,209,278,321,383,460,590,798,1140,1391,1543,1950,2626,3269,3983,5018,5683,6650,8077,9529,11658,14543,17089,19522,22141,25150]
	,'belgium' : [1,2,8,15,23,50,109,169,200,239,267,314,399,559,689,886,1058,1243,1486,1795,2257,2815,3401,3743,4269,4937,6235,7284,9134,10836,11899,12775]
}

new = {
	'poland' : [4,1,5,6,5,9,20,17,36,21,52,61,49,68,70,111,98,115,152,150,170,168,249,224,193,256]
	,'us' : [20,0,0,18,4,3,0,3,5,7,25,24,34,63,98,116,106,163,290,307,329,553,587,843,983,1748,2853,4582,5588,4825,9400,10189,11075,13355,17224,18691,19452,19913,20297,24742]
	,'germany' : [2,8,22,26,5,51,35,38,59,283,125,130,240,184,341,401,779,930,924,1214,1459,2095,2960,2993,4528,2516,2509,4183,3935,4332,6615,6933,6824,4740,4450,4923]
	,'spain' : [1,6,4,12,8,25,26,36,45,63,54,119,124,149,557,464,582,869,2086,1159,1597,1954,1884,2943,3308,3494,3925,3272,6368,6922,7457,8271,7933,7516,6875,7846]
	,'italy' : [1,17,58,78,72,94,147,185,234,239,573,335,466,587,769,778,1247,1492,1797,977,2313,2651,2547,3497,3590,3233,3526,4207,5322,5986,6557,5560,4789,5249,5210,6203,5909,5974,5217,4050,4053]
	,'france' : [2,4,20,19,43,30,61,21,73,138,230,296,260,203,372,497,595,785,838,924,1210,1097,1404,1861,1617,1847,1559,3838,2448,2929,3922,3809,4611,2599,4376,7578]
	,'canada' : [1,0,1,1,0,1,2,1,5,4,3,3,4,3,17,6,6,11,18,15,32,56,54,89,100,157,129,146,214,241,142,621,701,617,634,714,898,665,1128,1164]
	,'china' : [259,457,688,769,1771,1459,1737,1981,2099,2589,2825,3235,3884,3694,3143,3385,2652,2973,2467,2015,14108,5090,2641,2008,2048,1888,1749,391,889,823,648,214,508,406,433,327,427,573,202,125,119,139,143,99,44,40,19,24,15,20,11,20,16,21,13,34,39,41,46,39,78,47,67,55,54,45,0,79,36]
	,'iran' : [3,13,11,14,18,34,44,106,143,205,385,523,835,586,591,1234,1076,743,595,881,958,1075,1289,1365,1209,1053,1178,1192,1046,1237,966,1028,1411,1762,2206,2389,2926,3076,2901,3186,3110]
	,'uk' : [4,0,0,0,3,4,3,13,3,12,36,29,48,45,69,43,62,77,130,208,342,251,152,407,676,643,714,1035,665,967,1427,1452,2129,2885,2546,2433,2619,3009]
	,'belgium' : [1,6,7,8,27,59,60,31,39,28,47,85,160,130,197,172,185,243,309,462,558,586,342,526,668,1298,1049,1850,1702,1063,876]
}

for c in new:
	print(f'{c.upper()}:')
	pprint_digit_hist(new[c],1,None)
	print()

#s = int(f*100) * "*" # view-source:https://www.worldometers.info/coronavirus/country/us/