[['乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网', '乐视网'], ['300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104', '300104'], ['2018-03-30', '2018-03-29', '2018-03-28', '2018-03-23', '2018-03-22', '2018-03-21', '2018-03-20', '2018-03-19', '2018-03-16', '2018-03-14', '2018-03-13', '2018-03-12', '2018-03-09', '2018-03-08', '2018-03-07', '2018-03-06', '2018-03-05', '2018-03-02', '2018-03-01', '2018-02-28', '2018-02-27', '2018-02-26', '2018-02-23', '2018-02-22', '2018-02-14', '2018-02-13', '2018-02-12', '2018-02-09', '2018-02-08', '2018-02-07', '2018-02-06', '2018-02-05', '2018-02-02', '2018-02-01', '2018-01-31', '2018-01-30', '2018-01-29', '2018-01-26', '2018-01-25', '2018-01-24'], ['4.79', '5.11', '5.10', '5.40', '5.57', '5.70', '5.21', '5.34', '5.93', '6.49', '5.75', '5.41', '5.30', '5.32', '5.33', '5.33', '5.28', '5.15', '5.10', '5.27', '5.21', '5.09', '4.98', '4.47', '4.11', '4.47', '4.56', '4.57', '4.34', '4.82', '5.36', '5.95', '6.61', '7.34', '8.15', '9.05', '10.06', '11.18', '12.42', '13.80'], ['4.87', '5.11', '5.34', '5.48', '5.73', '5.88', '5.87', '5.34', '5.93', '6.77', '6.16', '5.65', '5.60', '5.45', '5.40', '5.48', '5.42', '5.70', '5.25', '5.54', '5.49', '5.37', '5.35', '4.86', '4.57', '4.51', '4.69', '4.92', '5.28', '4.82', '5.36', '5.95', '6.61', '7.34', '8.15', '9.05', '10.06', '11.18', '12.42', '13.80'], ['4.72', '4.70', '5.01', '4.99', '5.36', '5.30', '5.21', '5.34', '5.93', '6.36', '5.75', '5.38', '5.30', '5.27', '5.20', '5.32', '5.26', '5.09', '5.06', '5.11', '5.12', '5.02', '4.92', '4.35', '4.01', '4.12', '4.34', '4.57', '4.34', '4.82', '5.36', '5.95', '6.61', '7.34', '8.15', '9.05', '10.06', '11.18', '12.42', '13.80'], ['4.76', '4.78', '5.12', '5.08', '5.54', '5.53', '5.87', '5.34', '5.93', '6.59', '6.16', '5.60', '5.46', '5.35', '5.34', '5.38', '5.33', '5.50', '5.20', '5.22', '5.44', '5.28', '5.29', '4.86', '4.42', '4.16', '4.46', '4.57', '5.08', '4.82', '5.36', '5.95', '6.61', '7.34', '8.15', '9.05', '10.06', '11.18', '12.42', '13.80'], ['-0.02', '-0.34', '0.04', '-0.46', '0.01', '-0.34', '0.53', '-0.59', '-0.66', '0.43', '0.56', '0.14', '0.11', '0.01', '-0.04', '0.05', '-0.17', '0.30', '-0.02', '-0.22', '0.16', '-0.01', '0.43', '0.44', '0.26', '-0.30', '-0.11', '-0.51', '0.26', '-0.54', '-0.59', '-0.66', '-0.73', '-0.81', '-0.90', '-1.01', '-1.12', '-1.24', '-1.38', '-1.53'], ['-0.42', '-6.64', '0.79', '-8.30', '0.18', '-5.79', '9.93', '-9.95', '-10.02', '6.98', '10.00', '2.56', '2.06', '0.19', '-0.74', '0.94', '-3.09', '5.77', '-0.38', '-4.04', '3.03', '-0.19', '8.85', '9.95', '6.25', '-6.73', '-2.41', '-10.04', '5.39', '-10.07', '-9.92', '-9.98', '-9.95', '-9.94', '-9.94', '-10.04', '-10.02', '-9.98', '-10.00', '-9.98'], ['1,585,272', '2,889,496', '2,929,088', '2,663,670', '2,185,353', '3,907,513', '4,916,900', '454,889', '236,857', '3,782,598', '1,637,459', '2,695,850', '2,840,371', '1,568,980', '1,882,589', '1,886,108', '2,526,762', '4,395,146', '2,107,575', '3,583,972', '3,562,522', '3,955,894', '5,791,485', '2,824,080', '2,754,325', '2,821,280', '3,116,808', '5,324,391', '8,783,693', '822,437', '19,604', '17,324', '12,781', '9,753', '12,200', '9,785', '6,456', '10,162', '8,014', '24,286'], ['75,812', '139,091', '151,161', '138,534', '121,514', '221,070', '272,138', '24,291', '14,046', '248,715', '97,801', '148,498', '155,513', '83,928', '99,710', '101,605', '134,681', '238,821', '108,763', '189,997', '190,770', '205,485', '303,106', '129,186', '119,478', '121,624', '140,362', '247,522', '410,987', '39,641', '1,051', '1,031', '845', '716', '994', '886', '649', '1,136', '995', '3,351'], ['3.14', '8.01', '6.50', '8.84', '6.69', '9.88', '12.36', '0.00', '0.00', '6.66', '7.32', '4.95', '5.61', '3.37', '3.72', '3.00', '2.91', '11.73', '3.64', '7.90', '7.01', '6.62', '8.85', '11.54', '13.46', '8.74', '7.66', '6.89', '19.50', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00'], ['4.02', '7.33', '7.43', '6.76', '5.54', '9.91', '12.47', '1.15', '0.60', '9.60', '4.15', '6.84', '7.21', '3.98', '4.78', '4.78', '6.41', '11.15', '5.35', '9.09', '9.08', '10.09', '14.77', '7.20', '7.02', '7.19', '7.95', '13.58', '22.40', '2.22', '0.05', '0.05', '0.03', '0.03', '0.03', '0.03', '0.02', '0.03', '0.02', '0.07']]
数据格式如上。每个子列表的长度都是一样的。
想要循环成:
['万科A','000002','2018-07-30','9','20','8','8.9','-0.2','-0.2','85555','8.9','-0.2','1.5']
['万科A','000002','2018-07-30','9','20','8','8.9','-0.2','-0.2','85555','8.9','-0.2','1.5']
['万科A','000002','2018-07-30','9','20','8','8.9','-0.2','-0.2','85555','8.9','-0.2','1.5']
....
写一个循环也不是不可以,但是有更巧妙的方法。
先仔细观察一下可以发现你想把原数据表的行变成列,列变成行。可以考虑矩阵转置
转置就是行变成列,列变成行,比如这样:左边的第一行
5 4 3
变成了右边的第一列也可以用
map
和zip
来进行转置,这样就不用引入numpy
包。输出效果