-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdown_sampling.m
More file actions
31 lines (26 loc) · 1.06 KB
/
down_sampling.m
File metadata and controls
31 lines (26 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
clear
filename = 'JALSHRatios--PRIVILEGED-AND-CONFIDENTAIL.mat';
m = matfile(filename);
m.Properties.Writable = true;
JALSHRatios = rmmissing(m.JALSHRatios,2,'MinNumMissing',100);
[nrows,ncols] = size(JALSHRatios);
%Get the header
header = JALSHRatios.Properties.VariableNames';
%Filter out the header with key words
target = [];
for i = 1:ncols
expression = ['\w*ASSET\w*|\w*LIB\w*|\w*CASH\w*|\w*RATIO\w*|\w*PX\w*|\w*SH\w*|\w*EV\w*|'...
'\w*BOOK\w*|\w*CAPITAL\w*|\w*CAP\w*|\w*EARN\w*|\w*EPS\w*|\w*EARN\w*|\w*EPS\w*|\w*EBITDA\w*|'...
'\w*TO\w*|\w*EQUITY\w*|\w*MARGIN\w*'];
matchStr = regexp(header(i),expression,'match');
target= [target;matchStr];
end
columns_to_tailor_index = find(~cellfun(@isempty,target));
for i=1: length(columns_to_tailor_index)
theCol_index = columns_to_tailor_index(i);
theCol = table2array(JALSHRatios(:,theCol_index));
row_to_tailor_index = find(abs(diff(theCol))<0.01);
[theCol(row_to_tailor_index)]= deal(NaN);
JALSHRatios(:,theCol_index)= array2table(theCol);
end
writetable(JALSHRatios,'alinged_JALSHR.csv')