- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何使用 JavaScript 解析此 CSV?
1363085391,42.890000000000,5.432200000000
1363088879,47.570000000000,4.981800000000
1363120475,56.560000000000,1.768000000000
1363132522,53.000000000000,1.000000000000
1363214378,48.630000000000,4.000000000000
[...]
它显示了加元的 bitcoin price and trade volume history。然而,这个列表实在是太庞大了;它显示了曾经完成的每笔交易。因此,我试图将其从每天数百个数据点减少到每周一个。基本上通过将数量相加并平均价格来将数据点“货币化”为时间跨度间隔。这样,使用更简单的数据,my line chart 中的行预计看起来会好很多。
不幸的是,该脚本无法运行;它假设 CSV 是一个二维数组,但实际上我认为它只是一维?如何更改它以便正确解析 CSV?
function simplifyData(data_set) {
interval_length = 3600; // hourly intervals
last_price = 0;
idx = 0;
while (idx < data_set.length) {
// reset value for this interval
volume = 0;
price_sum = 0;
count = 0;
timestamp = data_set[idx]['timestamp'] + interval_length;
// get sums for this interval
while (data_set[idx]['timetamp'] < timestamp) {
volume += data_set[idx]['volume'];
price_sum += data_set[idx]['price'];
count++;
idx++;
if (idx >= data_set.length)
break;
}
// get average price
price = count > 0 ? price_sum / count : last_price;
last_price = price;
// add new row to monotized data array
monotized_data.append([
timestamp: timestamp,
volume: volume,
price: price
]);
}
}
// Format: time (UNIX timestamp), price, amount traded
// http://api.bitcoincharts.com/v1/csv/localbtcCAD.csv.gz
var complexCadCsv = "1363085391,42.890000000000,5.432200000000
1363088879,47.570000000000,4.981800000000
1363120475,56.560000000000,1.768000000000
1363132522,53.000000000000,1.000000000000
1363214378,48.630000000000,4.000000000000
1363217281,48.770000000000,2.000200000000
1363223157,48.860000000000,2.046500000000
1363232051,49.110000000000,4.235500000000
1363272551,54.250000000000,1.000000000000
1363283662,49.780000000000,5.925600000000
1363293072,55.500000000000,1.027000000000
1363321440,56.000000000000,5.357100000000
1363346950,55.220000000000,7.016900000000
1363379555,55.600000000000,4.945900000000
1363379607,55.740000000000,1.000000000000
1363381362,49.220000000000,0.101600000000
1363382662,49.220000000000,4.896100000000
1363391161,55.380000000000,2.000000000000
1363401704,56.060000000000,1.000000000000
1363467393,56.000000000000,0.892900000000
1363496639,56.700000000000,1.500100000000
1363524530,56.930000000000,6.000100000000
1363527377,56.900000000000,6.497900000000
1363542700,56.000000000000,2.142900000000
1363547113,55.000000000000,3.000000000000
1363564084,57.040000000000,2.156400000000
1363638453,57.880000000000,0.331700000000
1363729323,70.000000000000,0.857100000000
1363740718,73.070000000000,0.136800000000
1363795449,63.450000000000,1.000000000000
1363795494,63.860000000000,1.000100000000
1363795603,63.430000000000,0.157700000000
1363798700,68.390000000000,1.462200000000
1363800835,68.180000000000,1.991300000000
1363803497,67.940000000000,1.014600000000
1363803790,68.160000000000,1.027100000000
1363814790,69.580000000000,1.050000000000
1363814810,68.270000000000,0.929400000000
1363825583,68.250000000000,5.230600000000
1363829358,78.000000000000,1.050000000000
1363836583,83.300000000000,2.999800000000
1363837642,84.000000000000,2.000000000000
1363895966,75.410000000000,0.663000000000
1363944788,75.000000000000,4.000000000000
1363984884,90.000000000000,1.111100000000
1363987472,90.000000000000,1.111100000000
1363988438,89.350000000000,0.074000000000
1363989586,85.090000000000,1.999900000000
1364000191,88.000000000000,1.000000000000
1364002717,85.230000000000,1.490100000000
1364010104,70.730000000000,1.000000000000
1364013267,86.000000000000,1.162800000000
1364073182,78.000000000000,3.900000000000
1364089933,80.000000000000,3.025000000000
1364249509,74.360000000000,1.485600000000
1364262262,89.550000000000,1.116700000000
1364265293,90.040000000000,1.055000000000
1364310351,92.450000000000,1.081700000000
1364334487,81.210000000000,1.994800000000
1364355951,94.630000000000,1.420000000000
1364357864,95.380000000000,1.048400000000
1364358542,94.800000000000,1.054900000000
1364364067,82.820000000000,13.219800000000
1364395451,99.100000000000,0.100900000000
1364400184,102.700000000000,1.000000000000
1364401183,100.570000000000,1.093800000000
1364403945,101.420000000000,1.000000000000
1364411110,101.720000000000,0.498800000000
1364436263,106.740000000000,1.799900000000
1364436873,94.960000000000,1.000000000000
1364437451,94.520000000000,0.999900000000
1364440483,104.190000000000,0.499900000000
1364489123,109.760000000000,1.047800000000
1364490688,109.730000000000,1.000000000000
1364494732,100.230000000000,1.000000000000
1364498537,95.620000000000,1.950000000000
1364502332,95.780000000000,1.200700000000
1364505883,99.490000000000,0.251300000000
1364513250,103.900000000000,0.517100000000
1364516343,83.470000000000,1.018300000000
1364573738,97.140000000000,0.257400000000
1364580938,95.700000000000,1.000000000000
1364598407,102.000000000000,1.000000000000
1364600233,102.000000000000,1.000000000000
1364601641,102.000000000000,1.010000000000
1364605133,105.000000000000,1.000000000000
1364709921,99.880000000000,1.000000000000
1364712798,99.990000000000,1.000100000000
1364748894,101.470000000000,1.000000000000
1364755340,100.590000000000,3.000000000000
1364792969,106.000000000000,1.000000000000
1364799933,102.400000000000,1.000000000000
1364800923,101.560000000000,1.000000000000
1364828813,112.000000000000,2.000000000000
1364832014,115.000000000000,5.000000000000
1364832308,115.000000000000,3.000000000000
1364834249,112.720000000000,5.855000000000
1364838578,115.240000000000,5.727400000000
1364841672,104.360000000000,12.457200000000
1364923361,120.900000000000,2.999900000000
1364936087,120.710000000000,4.970600000000
1364948998,124.810000000000,4.999800000000
1364959661,127.170000000000,0.995000000000
1364965648,121.770000000000,1.000000000000
1364973827,136.060000000000,1.000000000000
1364974001,147.890000000000,4.000100000000
1364998794,140.320000000000,3.563200000000
1365026364,123.790000000000,1.015400000000
1365027711,127.780000000000,6.260900000000
1365046987,138.360000000000,4.000000000000
1365057275,138.500000000000,5.499900000000
1365065898,157.040000000000,1.999400000000
1365090058,145.220000000000,5.509000000000
1365104881,164.890000000000,5.458200000000
1365105565,139.710000000000,1.250000000000
1365138055,145.850000000000,1.849900000000
1365167322,166.250000000000,0.601500000000
1365173858,146.080000000000,1.999900000000
1365174283,148.260000000000,0.134900000000
1365183486,149.890000000000,3.000100000000
1365184905,161.740000000000,2.000100000000
1365205476,152.790000000000,1.000000000000
1365210365,175.000000000000,1.000000000000
1365219395,150.960000000000,0.999700000000
1365220927,150.910000000000,1.000000000000
1365268452,153.390000000000,0.652000000000
1365272285,170.000000000000,1.000000000000
1365274795,170.000000000000,1.000000000000
1365278764,170.000000000000,1.000000000000
1365278930,154.030000000000,0.519400000000
1365280374,170.000000000000,1.000000000000
1365281909,154.560000000000,0.650000000000
1365283450,170.000000000000,1.000000000000
1365287835,170.000000000000,1.541200000000
1365303267,153.940000000000,3.500100000000
1365312742,155.620000000000,0.128500000000
1365325139,161.570000000000,3.000000000000
1365349680,169.230000000000,2.000000000000
1365354798,138.110000000000,1.010000000000
1365356226,180.190000000000,1.664900000000
1365362290,174.010000000000,0.287300000000
1365377549,173.640000000000,2.000000000000
1365379774,175.010000000000,1.000000000000
1365384562,179.980000000000,2.222500000000
1365396478,183.290000000000,2.000000000000
1365434139,203.850000000000,0.098100000000
1365434614,208.360000000000,1.000000000000
1365437520,197.620000000000,2.000000000000
1365440837,195.520000000000,4.000000000000
1365449254,197.610000000000,4.000000000000
1365467994,202.160000000000,2.990500000000
1365469985,202.160000000000,1.500200000000
1365478982,206.360000000000,0.997700000000
1365479416,206.220000000000,1.000000000000
1365479554,203.290000000000,1.000000000000
1365486039,207.860000000000,0.465300000000
1365500973,219.210000000000,2.280900000000
1365518766,228.930000000000,1.970100000000
1365518846,225.910000000000,0.996000000000
1365520063,229.770000000000,0.747300000000
1365521859,235.270000000000,3.000000000000
1365521926,235.270000000000,0.850100000000
1365524515,240.510000000000,3.326200000000
1365524659,235.400000000000,0.999100000000
1365526701,238.440000000000,1.000000000000
1365527072,242.330000000000,2.000000000000
1365527199,240.510000000000,1.309700000000
1365529148,251.570000000000,1.000000000000
1365537800,265.560000000000,1.000000000000
1365542522,305.000000000000,1.508200000000
1365542586,305.000000000000,1.893400000000
1365551390,335.650000000000,0.715000000000
1365554253,265.540000000000,1.000000000000
1365558982,284.240000000000,1.000000000000
1365563330,306.440000000000,0.326300000000
1365566909,310.950000000000,0.064300000000
1365578721,338.530000000000,1.181600000000
1365606252,273.660000000000,1.000000000000
1365610294,281.800000000000,2.129200000000
1365612809,265.810000000000,2.000000000000
1365618499,262.140000000000,1.000000000000
1365628947,250.000000000000,1.944000000000
1365629291,253.640000000000,1.182800000000
1365642148,151.740000000000,2.000000000000
1365642413,141.270000000000,2.000000000000
1365678778,188.540000000000,3.993100000000
1365703940,148.580000000000,4.455400000000
1365716351,151.650000000000,0.680000000000
1365717197,136.400000000000,1.000000000000
1365717771,122.450000000000,1.951800000000
1365724442,124.000000000000,2.000000000000
1365773281,117.460000000000,1.251500000000
1365773887,121.000000000000,1.991800000000
1365776714,122.360000000000,2.231100000000
1365795875,114.590000000000,1.000000000000
1365796323,115.000000000000,2.000000000000
1365798963,106.190000000000,2.000000000000
1365802678,106.180000000000,1.000000000000
1365804038,111.410000000000,1.790000000000
1365810280,109.980000000000,1.500000000000
1365811712,115.000000000000,2.000000000000
1365813104,109.970000000000,1.000000000000
1365816966,165.200000000000,3.026600000000
1365819572,150.000000000000,1.066700000000
1365820699,128.730000000000,1.649900000000
1365823425,124.060000000000,3.224400000000
1365826775,150.000000000000,1.066700000000
1365877655,150.000000000000,2.000000000000
1365878739,159.330000000000,2.008500000000
1365884739,150.000000000000,4.000000000000
1365888397,150.000000000000,3.000000000000
1365956959,150.000000000000,5.330000000000
1365961896,140.000000000000,0.535700000000
1365979939,142.140000000000,1.000000000000
1365991144,128.990000000000,2.000000000000
1365993080,150.000000000000,1.333300000000
1366014910,135.000000000000,4.444400000000
1366022593,149.640000000000,0.467800000000
1366044482,123.500000000000,3.029100000000
1366045307,119.750000000000,1.002100000000
1366048928,119.750000000000,0.668100000000
1366055142,109.990000000000,0.181800000000
1366062216,109.480000000000,1.080000000000
1366065512,100.000000000000,0.181000000000
1366085870,88.150000000000,1.000000000000
1366085948,91.540000000000,0.436900000000
1366097421,74.700000000000,10.495300000000
1366129928,96.000000000000,2.083300000000
1366130124,99.720000000000,4.000000000000
1366133447,99.890000000000,1.000000000000
1366135520,103.730000000000,1.100000000000
1366138028,95.390000000000,1.100000000000
1366144237,69.480000000000,1.511300000000
1366145377,75.000000000000,2.586700000000
1366155682,89.800000000000,2.000000000000
1366158005,88.800000000000,1.000000000000
1366158456,89.800000000000,1.993300000000
1366164776,94.000000000000,2.000000000000
1366173698,102.640000000000,1.997400000000
1366198863,103.450000000000,1.991400000000
1366211035,102.450000000000,2.196200000000
1366218782,94.000000000000,3.000000000000
1366225431,94.000000000000,2.042600000000
1366233216,214.470000000000,1.000000000000
1366318951,108.730000000000,0.919700000000
1366387777,129.690000000000,1.982200000000
1366394307,135.420000000000,0.184600000000
1366413885,134.140000000000,0.298200000000
1366551162,136.710000000000,0.129600000000
1366553999,140.700000000000,2.487500000000
1366620334,137.830000000000,0.420800000000
1366671189,107.380000000000,1.500000000000
1366684569,141.740000000000,1.000000000000
1366686872,142.090000000000,1.055600000000
1366687106,142.130000000000,1.759000000000
1366746322,148.230000000000,3.373100000000
1366825778,159.250000000000,0.125600000000
1366903154,166.040000000000,1.540000000000
1366903247,168.230000000000,0.118900000000
1366906417,165.440000000000,1.588300000000
1366906495,166.300000000000,1.000000000000
1366912064,164.670000000000,2.130000000000
1366914573,164.820000000000,0.182000000000
1366978559,143.290000000000,1.395800000000
1367001597,144.390000000000,1.038900000000
1367002599,165.650000000000,1.000000000000
1367024672,142.890000000000,0.810000000000
1367027540,144.780000000000,1.450500000000
1367027692,146.310000000000,2.000000000000
1367029695,143.800000000000,0.750000000000
1367034952,143.800000000000,3.129500000000
1367043181,143.710000000000,2.261500000000
1367085501,141.190000000000,1.416600000000
1367100612,155.680000000000,1.281900000000
1367182014,170.140000000000,1.000000000000
1367182173,169.720000000000,1.119500000000
1367186205,170.710000000000,1.000000000000
1367275779,153.550000000000,1.465300000000
1367289143,198.350000000000,6.049900000000
1367323428,197.180000000000,7.000000000000
1367331486,155.660000000000,1.606000000000
1367348392,189.950000000000,5.264600000000
1367351603,146.060000000000,2.998800000000
1367356384,188.010000000000,7.138000000000
1367364586,167.170000000000,0.179500000000
1367364740,191.010000000000,7.853000000000
1367378952,165.000000000000,1.818200000000
1367423338,142.430000000000,3.931900000000
1367446179,133.240000000000,2.251600000000
1367457397,131.820000000000,1.273400000000
1367474137,129.410000000000,0.390000000000
1367506472,125.970000000000,0.079400000000
1367517588,112.580000000000,4.441400000000
1367534445,116.880000000000,0.171100000000
1367562381,108.910000000000,0.550900000000
1367591999,106.120000000000,0.471200000000
1367595257,104.460000000000,0.478600000000
1367599098,144.030000000000,1.041500000000
1367604271,99.230000000000,2.962700000000
1367625410,103.810000000000,2.022900000000"
var finalOutput = simplifyData(complexCadCsv);
$(".new_csv").append(finalOutput);
<!--<script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.min.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h1>New simplified CSV</h1>
<div class="new_csv"></div>
最佳答案
data_set
是一个字符串,但 simplifyData()
可以像访问对象数组一样访问它。您需要先将其转换。
data_set = data_set.split('\n').map(line => {
var linearray = line.split(',');
return {
timestamp: parseInt(linearray[0], 10),
price: parseFloat(linearray[1]),
volume: parseFloat(linearray[2])
};
});
在对 monotized_data.append
的调用中,当您应该使用大括号时,您却使用了方括号,并且您应该调用 push()
monotized_data.push({
timestamp: timestamp,
volume: volume,
price: price
});
function simplifyData(data_set) {
interval_length = 3600; // hourly intervals
last_price = 0;
idx = 0;
monotized_data = []
while (idx < data_set.length) {
// reset value for this interval
volume = 0;
price_sum = 0;
count = 0;
// Format: time (UNIX timestamp), price, amount traded
// timestamp: data_set[idx][0]
// price: data_set[idx][1]
// volume: data_set[idx][2]
timestamp = data_set[idx][0] + interval_length;
// get sums for this interval
while (data_set[idx][0] < timestamp) {
volume += data_set[idx][2];
price_sum += data_set[idx][1];
count++;
idx++;
if (idx >= data_set.length)
break;
}
// get average price
price = count > 0 ? price_sum / count : last_price;
last_price = price;
// add new row to monotized data array
monotized_data.push({
timestamp: timestamp,
volume: volume,
price: price
});
}
}
// Format: time (UNIX timestamp), price, amount traded
// http://api.bitcoincharts.com/v1/csv/localbtcCAD.csv.gz
var complexCadCsv = `1363085391,42.890000000000,5.432200000000
1363088879, 47.570000000000, 4.981800000000
1363120475, 56.560000000000, 1.768000000000
1363132522, 53.000000000000, 1.000000000000
1363214378, 48.630000000000, 4.000000000000
1363217281, 48.770000000000, 2.000200000000
1363223157, 48.860000000000, 2.046500000000
1363232051, 49.110000000000, 4.235500000000
1363272551, 54.250000000000, 1.000000000000
1363283662, 49.780000000000, 5.925600000000
1363293072, 55.500000000000, 1.027000000000
1363321440, 56.000000000000, 5.357100000000
1363346950, 55.220000000000, 7.016900000000
1363379555, 55.600000000000, 4.945900000000
1363379607, 55.740000000000, 1.000000000000
1363381362, 49.220000000000, 0.101600000000
1363382662, 49.220000000000, 4.896100000000
1363391161, 55.380000000000, 2.000000000000
1363401704, 56.060000000000, 1.000000000000
1363467393, 56.000000000000, 0.892900000000
1363496639, 56.700000000000, 1.500100000000
1363524530, 56.930000000000, 6.000100000000
1363527377, 56.900000000000, 6.497900000000
1363542700, 56.000000000000, 2.142900000000
1363547113, 55.000000000000, 3.000000000000
1363564084, 57.040000000000, 2.156400000000
1363638453, 57.880000000000, 0.331700000000
1363729323, 70.000000000000, 0.857100000000
1363740718, 73.070000000000, 0.136800000000
1363795449, 63.450000000000, 1.000000000000
1363795494, 63.860000000000, 1.000100000000
1363795603, 63.430000000000, 0.157700000000
1363798700, 68.390000000000, 1.462200000000
1363800835, 68.180000000000, 1.991300000000
1363803497, 67.940000000000, 1.014600000000
1363803790, 68.160000000000, 1.027100000000
1363814790, 69.580000000000, 1.050000000000
1363814810, 68.270000000000, 0.929400000000
1363825583, 68.250000000000, 5.230600000000
1363829358, 78.000000000000, 1.050000000000
1363836583, 83.300000000000, 2.999800000000
1363837642, 84.000000000000, 2.000000000000
1363895966, 75.410000000000, 0.663000000000
1363944788, 75.000000000000, 4.000000000000
1363984884, 90.000000000000, 1.111100000000
1363987472, 90.000000000000, 1.111100000000
1363988438, 89.350000000000, 0.074000000000
1363989586, 85.090000000000, 1.999900000000
1364000191, 88.000000000000, 1.000000000000
1364002717, 85.230000000000, 1.490100000000
1364010104, 70.730000000000, 1.000000000000
1364013267, 86.000000000000, 1.162800000000
1364073182, 78.000000000000, 3.900000000000
1364089933, 80.000000000000, 3.025000000000
1364249509, 74.360000000000, 1.485600000000
1364262262, 89.550000000000, 1.116700000000
1364265293, 90.040000000000, 1.055000000000
1364310351, 92.450000000000, 1.081700000000
1364334487, 81.210000000000, 1.994800000000
1364355951, 94.630000000000, 1.420000000000
1364357864, 95.380000000000, 1.048400000000
1364358542, 94.800000000000, 1.054900000000
1364364067, 82.820000000000, 13.219800000000
1364395451, 99.100000000000, 0.100900000000
1364400184, 102.700000000000, 1.000000000000
1364401183, 100.570000000000, 1.093800000000
1364403945, 101.420000000000, 1.000000000000
1364411110, 101.720000000000, 0.498800000000
1364436263, 106.740000000000, 1.799900000000
1364436873, 94.960000000000, 1.000000000000
1364437451, 94.520000000000, 0.999900000000
1364440483, 104.190000000000, 0.499900000000
1364489123, 109.760000000000, 1.047800000000
1364490688, 109.730000000000, 1.000000000000
1364494732, 100.230000000000, 1.000000000000
1364498537, 95.620000000000, 1.950000000000
1364502332, 95.780000000000, 1.200700000000
1364505883, 99.490000000000, 0.251300000000
1364513250, 103.900000000000, 0.517100000000
1364516343, 83.470000000000, 1.018300000000
1364573738, 97.140000000000, 0.257400000000
1364580938, 95.700000000000, 1.000000000000
1364598407, 102.000000000000, 1.000000000000
1364600233, 102.000000000000, 1.000000000000
1364601641, 102.000000000000, 1.010000000000
1364605133, 105.000000000000, 1.000000000000
1364709921, 99.880000000000, 1.000000000000
1364712798, 99.990000000000, 1.000100000000
1364748894, 101.470000000000, 1.000000000000
1364755340, 100.590000000000, 3.000000000000
1364792969, 106.000000000000, 1.000000000000
1364799933, 102.400000000000, 1.000000000000
1364800923, 101.560000000000, 1.000000000000
1364828813, 112.000000000000, 2.000000000000
1364832014, 115.000000000000, 5.000000000000
1364832308, 115.000000000000, 3.000000000000
1364834249, 112.720000000000, 5.855000000000
1364838578, 115.240000000000, 5.727400000000
1364841672, 104.360000000000, 12.457200000000
1364923361, 120.900000000000, 2.999900000000
1364936087, 120.710000000000, 4.970600000000
1364948998, 124.810000000000, 4.999800000000
1364959661, 127.170000000000, 0.995000000000
1364965648, 121.770000000000, 1.000000000000
1364973827, 136.060000000000, 1.000000000000
1364974001, 147.890000000000, 4.000100000000
1364998794, 140.320000000000, 3.563200000000
1365026364, 123.790000000000, 1.015400000000
1365027711, 127.780000000000, 6.260900000000
1365046987, 138.360000000000, 4.000000000000
1365057275, 138.500000000000, 5.499900000000
1365065898, 157.040000000000, 1.999400000000
1365090058, 145.220000000000, 5.509000000000
1365104881, 164.890000000000, 5.458200000000
1365105565, 139.710000000000, 1.250000000000
1365138055, 145.850000000000, 1.849900000000
1365167322, 166.250000000000, 0.601500000000
1365173858, 146.080000000000, 1.999900000000
1365174283, 148.260000000000, 0.134900000000
1365183486, 149.890000000000, 3.000100000000
1365184905, 161.740000000000, 2.000100000000
1365205476, 152.790000000000, 1.000000000000
1365210365, 175.000000000000, 1.000000000000
1365219395, 150.960000000000, 0.999700000000
1365220927, 150.910000000000, 1.000000000000
1365268452, 153.390000000000, 0.652000000000
1365272285, 170.000000000000, 1.000000000000
1365274795, 170.000000000000, 1.000000000000
1365278764, 170.000000000000, 1.000000000000
1365278930, 154.030000000000, 0.519400000000
1365280374, 170.000000000000, 1.000000000000
1365281909, 154.560000000000, 0.650000000000
1365283450, 170.000000000000, 1.000000000000
1365287835, 170.000000000000, 1.541200000000
1365303267, 153.940000000000, 3.500100000000
1365312742, 155.620000000000, 0.128500000000
1365325139, 161.570000000000, 3.000000000000
1365349680, 169.230000000000, 2.000000000000
1365354798, 138.110000000000, 1.010000000000
1365356226, 180.190000000000, 1.664900000000
1365362290, 174.010000000000, 0.287300000000
1365377549, 173.640000000000, 2.000000000000
1365379774, 175.010000000000, 1.000000000000
1365384562, 179.980000000000, 2.222500000000
1365396478, 183.290000000000, 2.000000000000
1365434139, 203.850000000000, 0.098100000000
1365434614, 208.360000000000, 1.000000000000
1365437520, 197.620000000000, 2.000000000000
1365440837, 195.520000000000, 4.000000000000
1365449254, 197.610000000000, 4.000000000000
1365467994, 202.160000000000, 2.990500000000
1365469985, 202.160000000000, 1.500200000000
1365478982, 206.360000000000, 0.997700000000
1365479416, 206.220000000000, 1.000000000000
1365479554, 203.290000000000, 1.000000000000
1365486039, 207.860000000000, 0.465300000000
1365500973, 219.210000000000, 2.280900000000
1365518766, 228.930000000000, 1.970100000000
1365518846, 225.910000000000, 0.996000000000
1365520063, 229.770000000000, 0.747300000000
1365521859, 235.270000000000, 3.000000000000
1365521926, 235.270000000000, 0.850100000000
1365524515, 240.510000000000, 3.326200000000
1365524659, 235.400000000000, 0.999100000000
1365526701, 238.440000000000, 1.000000000000
1365527072, 242.330000000000, 2.000000000000
1365527199, 240.510000000000, 1.309700000000
1365529148, 251.570000000000, 1.000000000000
1365537800, 265.560000000000, 1.000000000000
1365542522, 305.000000000000, 1.508200000000
1365542586, 305.000000000000, 1.893400000000
1365551390, 335.650000000000, 0.715000000000
1365554253, 265.540000000000, 1.000000000000
1365558982, 284.240000000000, 1.000000000000
1365563330, 306.440000000000, 0.326300000000
1365566909, 310.950000000000, 0.064300000000
1365578721, 338.530000000000, 1.181600000000
1365606252, 273.660000000000, 1.000000000000
1365610294, 281.800000000000, 2.129200000000
1365612809, 265.810000000000, 2.000000000000
1365618499, 262.140000000000, 1.000000000000
1365628947, 250.000000000000, 1.944000000000
1365629291, 253.640000000000, 1.182800000000
1365642148, 151.740000000000, 2.000000000000
1365642413, 141.270000000000, 2.000000000000
1365678778, 188.540000000000, 3.993100000000
1365703940, 148.580000000000, 4.455400000000
1365716351, 151.650000000000, 0.680000000000
1365717197, 136.400000000000, 1.000000000000
1365717771, 122.450000000000, 1.951800000000
1365724442, 124.000000000000, 2.000000000000
1365773281, 117.460000000000, 1.251500000000
1365773887, 121.000000000000, 1.991800000000
1365776714, 122.360000000000, 2.231100000000
1365795875, 114.590000000000, 1.000000000000
1365796323, 115.000000000000, 2.000000000000
1365798963, 106.190000000000, 2.000000000000
1365802678, 106.180000000000, 1.000000000000
1365804038, 111.410000000000, 1.790000000000
1365810280, 109.980000000000, 1.500000000000
1365811712, 115.000000000000, 2.000000000000
1365813104, 109.970000000000, 1.000000000000
1365816966, 165.200000000000, 3.026600000000
1365819572, 150.000000000000, 1.066700000000
1365820699, 128.730000000000, 1.649900000000
1365823425, 124.060000000000, 3.224400000000
1365826775, 150.000000000000, 1.066700000000
1365877655, 150.000000000000, 2.000000000000
1365878739, 159.330000000000, 2.008500000000
1365884739, 150.000000000000, 4.000000000000
1365888397, 150.000000000000, 3.000000000000
1365956959, 150.000000000000, 5.330000000000
1365961896, 140.000000000000, 0.535700000000
1365979939, 142.140000000000, 1.000000000000
1365991144, 128.990000000000, 2.000000000000
1365993080, 150.000000000000, 1.333300000000
1366014910, 135.000000000000, 4.444400000000
1366022593, 149.640000000000, 0.467800000000
1366044482, 123.500000000000, 3.029100000000
1366045307, 119.750000000000, 1.002100000000
1366048928, 119.750000000000, 0.668100000000
1366055142, 109.990000000000, 0.181800000000
1366062216, 109.480000000000, 1.080000000000
1366065512, 100.000000000000, 0.181000000000
1366085870, 88.150000000000, 1.000000000000
1366085948, 91.540000000000, 0.436900000000
1366097421, 74.700000000000, 10.495300000000
1366129928, 96.000000000000, 2.083300000000
1366130124, 99.720000000000, 4.000000000000
1366133447, 99.890000000000, 1.000000000000
1366135520, 103.730000000000, 1.100000000000
1366138028, 95.390000000000, 1.100000000000
1366144237, 69.480000000000, 1.511300000000
1366145377, 75.000000000000, 2.586700000000
1366155682, 89.800000000000, 2.000000000000
1366158005, 88.800000000000, 1.000000000000
1366158456, 89.800000000000, 1.993300000000
1366164776, 94.000000000000, 2.000000000000
1366173698, 102.640000000000, 1.997400000000
1366198863, 103.450000000000, 1.991400000000
1366211035, 102.450000000000, 2.196200000000
1366218782, 94.000000000000, 3.000000000000
1366225431, 94.000000000000, 2.042600000000
1366233216, 214.470000000000, 1.000000000000
1366318951, 108.730000000000, 0.919700000000
1366387777, 129.690000000000, 1.982200000000
1366394307, 135.420000000000, 0.184600000000
1366413885, 134.140000000000, 0.298200000000
1366551162, 136.710000000000, 0.129600000000
1366553999, 140.700000000000, 2.487500000000
1366620334, 137.830000000000, 0.420800000000
1366671189, 107.380000000000, 1.500000000000
1366684569, 141.740000000000, 1.000000000000
1366686872, 142.090000000000, 1.055600000000
1366687106, 142.130000000000, 1.759000000000
1366746322, 148.230000000000, 3.373100000000
1366825778, 159.250000000000, 0.125600000000
1366903154, 166.040000000000, 1.540000000000
1366903247, 168.230000000000, 0.118900000000
1366906417, 165.440000000000, 1.588300000000
1366906495, 166.300000000000, 1.000000000000
1366912064, 164.670000000000, 2.130000000000
1366914573, 164.820000000000, 0.182000000000
1366978559, 143.290000000000, 1.395800000000
1367001597, 144.390000000000, 1.038900000000
1367002599, 165.650000000000, 1.000000000000
1367024672, 142.890000000000, 0.810000000000
1367027540, 144.780000000000, 1.450500000000
1367027692, 146.310000000000, 2.000000000000
1367029695, 143.800000000000, 0.750000000000
1367034952, 143.800000000000, 3.129500000000
1367043181, 143.710000000000, 2.261500000000
1367085501, 141.190000000000, 1.416600000000
1367100612, 155.680000000000, 1.281900000000
1367182014, 170.140000000000, 1.000000000000
1367182173, 169.720000000000, 1.119500000000
1367186205, 170.710000000000, 1.000000000000
1367275779, 153.550000000000, 1.465300000000
1367289143, 198.350000000000, 6.049900000000
1367323428, 197.180000000000, 7.000000000000
1367331486, 155.660000000000, 1.606000000000
1367348392, 189.950000000000, 5.264600000000
1367351603, 146.060000000000, 2.998800000000
1367356384, 188.010000000000, 7.138000000000
1367364586, 167.170000000000, 0.179500000000
1367364740, 191.010000000000, 7.853000000000
1367378952, 165.000000000000, 1.818200000000
1367423338, 142.430000000000, 3.931900000000
1367446179, 133.240000000000, 2.251600000000
1367457397, 131.820000000000, 1.273400000000
1367474137, 129.410000000000, 0.390000000000
1367506472, 125.970000000000, 0.079400000000
1367517588, 112.580000000000, 4.441400000000
1367534445, 116.880000000000, 0.171100000000
1367562381, 108.910000000000, 0.550900000000
1367591999, 106.120000000000, 0.471200000000
1367595257, 104.460000000000, 0.478600000000
1367599098, 144.030000000000, 1.041500000000
1367604271, 99.230000000000, 2.962700000000
1367625410, 103.810000000000, 2.022900000000`
// Parse the multi-line CSV string above into a 2D array
var complexCadCsvArray = $.csv.toArrays(complexCadCsv);
// jquery-csv `toArrays` are strings, needs to be number
// Trim whitespace and then convert to Number
var complexCadCsvJsArrayNumbers = complexCadCsvArray.map(row => row.map(el => Number(el.trim())));
// Reduce trade times to same-sized intervals
simplifyData(complexCadCsvJsArrayNumbers);
$(".new_csv").text($.csv.fromObjects(monotized_data));
// ----------
$(".existing_csv").append(complexCadCsvArray);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.min.js"></script>
<h1>New simplified CSV</h1>
<pre class="new_csv"></pre>
<h1>Existing CSV run through <a href="https://github.com/evanplaice/jquery-csv">jquery-csv</a></h1>
<pre class="existing_csv"></pre>
关于javascript - 使我的 JavaScript(假定 CSV 是二维的)适用于一维 CSV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46057922/
我在我的 Xcode 项目目录中输入了以下内容: keytool -genkey -v -keystore release.keystore -alias mykey -keyalg RSA \
假设我有一个像这样的 DataFrame(或 Series): Value 0 0.5 1 0.8 2 -0.2 3 None 4 None 5 None
我正在对一个 Pandas 系列进行相对繁重的应用。有什么方法可以返回一些打印反馈,说明每次调用函数时在函数内部进行打印还有多远? 最佳答案 您可以使用跟踪器包装您的函数。以下两个示例,一个基于完成的
我有一个 DataFrame,其中一列包含列表作为单元格内容,如下所示: import pandas as pd df = pd.DataFrame({ 'col_lists': [[1, 2
我想使用 Pandas df.apply 但仅限于某些行 作为一个例子,我想做这样的事情,但我的实际问题有点复杂: import pandas as pd import math z = pd.Dat
我有以下 Pandas 数据框 id dist ds 0 0 0 0 5 1 0 0 7 2 0 0
这发生在我尝试使用 Gradle 构建时。由于字符串是对象,因此似乎没有理由发生此错误: No signature of method: java.util.HashMap.getOrDefault(
您好,有人可以解释为什么在 remaining() 函数中的 Backbone 示例应用程序 ( http://backbonejs.org/examples/todos/index.html ) 中
我有两个域类:用户 class User { String username String password String email Date dateCreated
问题陈述: 一个 pandas dataframe 列系列,same_group 需要根据两个现有列 row 和 col 的值从 bool 值创建。如果两个值在字典 memberships 中具有相似
apporable 报告以下错误: error: unknown type name 'MKMapItem'; did you mean 'MKMapView'? MKMapItem* destina
我有一个带有地址列的大型 DataFrame: data addr 0 0.617964 IN,Krishnagiri,635115 1 0.635428 IN,Chennai
我有一个列表list,里面有这样的项目 ElementA: Number=1, Version=1 ElementB: Number=1, Version=2 ElementC: Number=1,
我正在编译我的源代码,它只是在没有运行应用程序的情况下终止。这是我得到的日志: Build/android-armeabi-debug/com.app4u.portaldorugby/PortalDo
我正在尝试根据另一个单元格的值更改单元格值(颜色“红色”或“绿色”)。我运行以下命令: df.loc[0, 'Colour'] = df.loc[0, 'Count'].apply(lambda x:
我想弄清楚如何使用 StateT结合两个 State基于对我的 Scalaz state monad examples 的评论的状态转换器回答。 看来我已经很接近了,但是在尝试申请 sequence
如果我已经为它绑定(bind)了集合,我该如何添加 RibbonLibrary 默认的快速访问项容器。当我从 UI 添加快速访问工具项时,它会抛出 Operation is not valid whi
在我学习期间Typoclassopedia我遇到了这个证明,但我不确定我的证明是否正确。问题是: One might imagine a variant of the interchange law
我是一名优秀的程序员,十分优秀!