鱼C论坛

 找回密码
 立即注册
查看: 2201|回复: 1

[已解决]规律数据提取的问题,请大师帮忙看看

[复制链接]
发表于 2022-12-7 21:53:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
数据:
"data":[["2022-12-02",2383.32,2408.74,2378.40,2369.31,2383.32,2.14,"0.09%",460.73,1260.83,null],["2022-12-01",2381.18,2403.77,2386.08,2380.67,2381.18,35.87,"1.53%",689.54,1763.01,null],["2022-11-30",2345.31,2348.16,2335.95,2323.19,2345.31,5.52,"0.24%",503.28,1320.09,null],["2022-11-29",2339.79,2347.71,2301.21,2298.31,2339.79,40.99,"1.78%",545.52,1581.91,null],["2022-11-28",2298.80,2300.95,2264.83,2261.05,2298.80,-10.56,"-0.46%",400.68,1126.00,null],["2022-11-25",2309.36,2327.28,2325.57,2304.98,2309.36,-26.16,"-1.12%",348.98,947.76,null],["2022-11-24",2335.52,2356.67,2349.27,2330.37,2335.52,-4.82,"-0.21%",385.33,996.35,null],["2022-11-08",2432.40,2460.99,2452.86,2411.72,2432.40,-22.29,"-0.91%",530.44,1345.00,null],["2022-11-07",2454.69,2470.64,2447.13,2432.05,2454.69,3.47,"0.14%",638.18,1656.64,null]]

想提取每个日期及对应的第二个和第四个数据,如第一个为:"2022-12-02",2408.74,2369.31 ....
求大师帮忙指点下
最佳答案
2022-12-7 22:04:30
data = [["2022-12-02",2383.32,2408.74,2378.40,2369.31,2383.32,2.14,"0.09%",460.73,1260.83,"null"],["2022-12-01",2381.18,2403.77,2386.08,2380.67,2381.18,35.87,"1.53%",689.54,1763.01,"null"],["2022-11-30",2345.31,2348.16,2335.95,2323.19,2345.31,5.52,"0.24%",503.28,1320.09,"null"],["2022-11-29",2339.79,2347.71,2301.21,2298.31,2339.79,40.99,"1.78%",545.52,1581.91,"null"],["2022-11-28",2298.80,2300.95,2264.83,2261.05,2298.80,-10.56,"-0.46%",400.68,1126.00,"null"],["2022-11-25",2309.36,2327.28,2325.57,2304.98,2309.36,-26.16,"-1.12%",348.98,947.76,"null"],["2022-11-24",2335.52,2356.67,2349.27,2330.37,2335.52,-4.82,"-0.21%",385.33,996.35,"null"],["2022-11-08",2432.40,2460.99,2452.86,2411.72,2432.40,-22.29,"-0.91%",530.44,1345.00,"null"],["2022-11-07",2454.69,2470.64,2447.13,2432.05,2454.69,3.47,"0.14%",638.18,1656.64,"null"]]
result = []
for each in data:
    result.append((each[0], each[2], each[4]))  
print(result)
[('2022-12-02', 2408.74, 2369.31), ('2022-12-01', 2403.77, 2380.67), ('2022-11-30', 2348.16, 2323.19), ('2022-11-29', 2347.71, 2298.31), ('2022-11-28', 2300.95, 2261.05), ('2022-11-25', 2327.28, 2304.98), ('2022-11-24', 2356.67, 2330.37), ('2022-11-08', 2460.99, 2411.72), ('2022-11-07', 2470.64, 2432.05)]
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-12-7 22:04:30 | 显示全部楼层    本楼为最佳答案   
data = [["2022-12-02",2383.32,2408.74,2378.40,2369.31,2383.32,2.14,"0.09%",460.73,1260.83,"null"],["2022-12-01",2381.18,2403.77,2386.08,2380.67,2381.18,35.87,"1.53%",689.54,1763.01,"null"],["2022-11-30",2345.31,2348.16,2335.95,2323.19,2345.31,5.52,"0.24%",503.28,1320.09,"null"],["2022-11-29",2339.79,2347.71,2301.21,2298.31,2339.79,40.99,"1.78%",545.52,1581.91,"null"],["2022-11-28",2298.80,2300.95,2264.83,2261.05,2298.80,-10.56,"-0.46%",400.68,1126.00,"null"],["2022-11-25",2309.36,2327.28,2325.57,2304.98,2309.36,-26.16,"-1.12%",348.98,947.76,"null"],["2022-11-24",2335.52,2356.67,2349.27,2330.37,2335.52,-4.82,"-0.21%",385.33,996.35,"null"],["2022-11-08",2432.40,2460.99,2452.86,2411.72,2432.40,-22.29,"-0.91%",530.44,1345.00,"null"],["2022-11-07",2454.69,2470.64,2447.13,2432.05,2454.69,3.47,"0.14%",638.18,1656.64,"null"]]
result = []
for each in data:
    result.append((each[0], each[2], each[4]))  
print(result)
[('2022-12-02', 2408.74, 2369.31), ('2022-12-01', 2403.77, 2380.67), ('2022-11-30', 2348.16, 2323.19), ('2022-11-29', 2347.71, 2298.31), ('2022-11-28', 2300.95, 2261.05), ('2022-11-25', 2327.28, 2304.98), ('2022-11-24', 2356.67, 2330.37), ('2022-11-08', 2460.99, 2411.72), ('2022-11-07', 2470.64, 2432.05)]
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 2 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-15 20:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表