我想要使用的数据库制作一个数字列表,这样我就可以计算整个数据库中每个数字出现的次数。我想使用Number_1 - Number_5列。我能做的最多就是为每一列制作单独的列表。 为了进一步澄清,我希望列表看起来像这样: list_of_numbers =(11,18,5,14,31,26,12,37,12,13,3,2,4,14,41,22,31,26,15,35,32,20,49,20 ,15,7,5,10,18,58,...)
顺便说一下,数据库非常大,所以列表中有7650个元素 它看起来像这样: Draw # Draw DateNumber_1Number_2Number_3Number_4Number_5Mega
1004 Tue. Feb 03, 2015 11 22 25 58 69 13
1003 Fri. Jan 30, 2015 18 31 39 45 55 6
1002 Tue. Jan 27, 2015 5 26 27 44 57 7
1001 Fri. Jan 23, 2015 14 15 32 68 72 8
1000 Tue. Jan 20, 2015 31 35 56 59 63 6
999 Fri. Jan 16, 2015 26 32 44 45 58 11
998 Tue. Jan 13, 2015 12 20 25 50 51 7
997 Fri. Jan 09, 2015 37 49 50 56 57 8
996 Tue. Jan 06, 2015 12 20 27 38 75 4
995 Fri. Jan 02, 2015 13 15 35 62 74 12
994 Tue. Dec 30, 2014 3 7 44 63 67 12
993 Fri. Dec 26, 2014 2 5 10 20 38 14
992 Tue. Dec 23, 2014 4 10 31 56 66 7
991 Fri. Dec 19, 2014 14 18 58 59 68 4
990 Tue. Dec 16, 2014 41 58 68 72 73 1
答案 0 :(得分:4)
df.iloc[:, -6: -1].values.T.ravel()
产量
array([11, 18, 5, 14, 31, 26, 12, 37, 12, 13, 3, 2, 4, 14, 41, 18, 5,
14, 31, 26, 12, 37, 12, 13, 3, 2, 4, 14, 41, 31, 26, 15, 35, 32,
20, 49, 20, 15, 7, 5, 10, 18, 58, 39, 27, 32, 56, 44, 25, 50, 27,
35, 44, 10, 31, 58, 68, 45, 44, 68, 59, 45, 50, 56, 38, 62, 63, 20,
56, 59, 72, 55, 57, 72, 63, 58, 51, 57, 75, 74, 67, 38, 66, 68, 73,
6, 7, 8, 6, 11, 7, 8, 4, 12, 12, 14, 7, 4, 1])
如果您更喜欢列表,可以在结果数组上调用tolist()
方法。