How to extracy table rows by date?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How can one extract table rows by unique dates? If there is a data set where the first column is the date (MM/dd/yyyy), can one create a matrix with unique dates and then extract for each only the rows containing that date?
ExpirationDates = quotedata(:,1); %extract expiration dates
uniqueDates = unique(ExpirationDates); %build expiration dates table
quotedata = table2timetable(quotedata);
for k=1:height(uniqueDates)
thisDate = (uniqueDates(k,:));
indexesWithThisDate = (ExpirationDates == thisDate);
% Extract all rows with this date and put into a cell array.
theseData = array(indexesWithThisDate, 12); % Get col 12
% Assign to a new cell
ca{k} = theseData;
end
I get the following error message:
"Undefined operator '==' for input arguments of type 'table'.
Error in QuotesProcessor (line 13)
indexesWithThisDate = (ExpirationDates == thisDate);"
0 comentarios
Respuestas (1)
Peter Perkins
el 14 de Mayo de 2019
Looking at your code, you seem to be creating a timetable with no data, just row times. That doesn't seem useful. But then "array" is, maybe, a table or something with data? This doesn't seem the right way to go about things.
The answer to your specific question is, (ExpirationDates.Time == thisDate). But there have to be better ways to go about whatever it is you are doing.
0 comentarios
Ver también
Categorías
Más información sobre Time Series Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!