From f937c697a49845985335dfc7f7a2e16910381c58 Mon Sep 17 00:00:00 2001 From: chenwj113 Date: Wed, 12 Oct 2022 16:54:26 +0800 Subject: [PATCH] add sd.py --- sd.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sd.py diff --git a/sd.py b/sd.py new file mode 100644 index 0000000..9947fdb --- /dev/null +++ b/sd.py @@ -0,0 +1,16 @@ +import numpy as np +import pandas as pd + +a = np.arange(1000) + +l = set([ f"{i:03d}" for i in a ]) + +sum_dict = dict() +print(len(l)) +for i in l: + _sum = sum(map(int, i)) + v = sum_dict.get(_sum, 0) + sum_dict[_sum] = v + 1 + +df = pd.Series(sum_dict) +print(df.sort_values(ascending=False)) \ No newline at end of file