Tall array - How can I perform conditional search and extract information
Show older comments
Hi, I am in much need of help here.
I have a tall array (40million rows)
Column1 (Customer ID) - there are 2000 customers for each Date sample
Column 2 (Date sample, based on half hour) - i.e. 2019-12-31 00:30:00, 2019-12-31 01:30:00,
Column 5 (Price)
I need to find the highest price for each Customer within 1 day (i.e. within 48 date samples)
then I need to write the selected columns to csv file.
I have been trying loops without luck :(
The code below seems to accumulate into bins based on sample
ds = datastore('File.csv');
tt = tall(ds);
tt = rmmissing(tt);
g=findgroups(tt.datesample); %this is selecting based on sample not per day ?
bin = splitapply(@(v, d) {sum(v), d(1)}, tt.output, tt.datesample, g); %can sum be replaced with max?
gatherbin = gather(bin);
tablebin = cell2table(gatherbin);
writetable(tablebin,'newfile.csv');
1 Comment
dpb
on 4 Aug 2019
I've not worked with tall arrays "in anger" so not too sure about what does/doesn't work correctly with ordinary syntax.
But, I'd try to create a time table then group by customer. Then retime with aggregation function max should be what you're looking for...
Accepted Answer
More Answers (1)
George Kharoufeh
on 6 Aug 2019
0 votes
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!