SHARE
TWEET

Untitled

a guest Oct 18th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. clear
  2. clc
  3.  
  4. load midwest
  5.  
  6. data = intermediate;
  7.  
  8. uniqueZIPs = unique(data(:,2)); % get all the unique zip codes aka the final dataset
  9.  
  10. % count = 0; % not sure what this is used for
  11.  
  12. staralliance = {'JP','A3','AC','CA','AI','NZ','NH','OZ','OS','AV','SN','OU',...
  13.     'CM','MS','ET','BR','LO','LH','SK','ZH','SQ','SA','LX','TP','TG','TK','UA'};
  14. oneworld = {'US','AB','AA','BA','CX','AY','IB','JL','LA','MH','QF','QR','RJ'...
  15.     'S7','UL','JJ'};
  16. skyteam = {'SU','AR','AM','UX','AF','AZ','CI','MU','CZ','OK','DL','GA','KQ'...
  17.     'KL','KE','ME','SV','RO','VN','MF'};
  18. container = {staralliance,oneworld,skyteam};
  19.  
  20. for i = 1:length(uniqueZIPs)
  21.     %% Admin
  22.     if mod(i,50) == 0
  23.         disp(i)
  24.     end
  25.     filter = data(strcmp(data(:,2),uniqueZIPs{i}),:); % find in dataset where this unique zip is held
  26.    
  27.     totalpax = sum(cell2mat(filter(:,4)));
  28.     %% ORD Pax
  29.     AP_ORDpax = sum(cell2mat(filter(strcmp(filter(:,1),'ORD'),4)));
  30.     AP_nonORDpax = sum(cell2mat(filter(~strcmp(filter(:,1),'ORD'),4)));
  31.    
  32.     %% DTW Pax
  33.     AP_DTWpax = sum(cell2mat(filter(strcmp(filter(:,1),'DTW'),4)));
  34.     AP_nonDTWpax = sum(cell2mat(filter(~strcmp(filter(:,1),'DTW'),4)));
  35.    
  36.     %% MSP Pax
  37.     AP_MSPpax = sum(cell2mat(filter(strcmp(filter(:,1),'MSP'),4)));
  38.     AP_nonMSPpax = sum(cell2mat(filter(~strcmp(filter(:,1),'MSP'),4)));
  39.    
  40.     %% AA Pax
  41.     AL_AApax = sum(cell2mat(filter(strcmp(filter(:,3),'AA'),4)));
  42.     AL_nonAApax = sum(cell2mat(filter(~strcmp(filter(:,3),'AA'),4)));
  43.    
  44.     %% DL Pax
  45.     AL_DLpax = sum(cell2mat(filter(strcmp(filter(:,3),'DL'),4)));
  46.     AL_nonDLpax = sum(cell2mat(filter(~strcmp(filter(:,3),'DL'),4)));
  47.    
  48.     %% UA Pax
  49.     AL_UApax = sum(cell2mat(filter(strcmp(filter(:,3),'UA'),4)));
  50.     AL_nonUApax = sum(cell2mat(filter(~strcmp(filter(:,3),'UA'),4)));
  51.    
  52.     %% US Pax
  53.     AL_USpax = sum(cell2mat(filter(strcmp(filter(:,3),'US'),4)));
  54.     AL_nonUSpax = sum(cell2mat(filter(~strcmp(filter(:,3),'US'),4)));
  55.    
  56.     %% ORD hubbing
  57.     AP_AAUAPax = AL_UApax + AL_AApax;
  58.     AP_xAAUAPax = totalpax - AP_AAUAPax;
  59.    
  60.     %% Hub or non-hub
  61.     HUB = AP_DTWpax + AP_MSPpax + AP_ORDpax;
  62.     nonhub = totalpax - HUB;
  63.    
  64.     %% alliance counts
  65.    
  66.   pax = 0;
  67.     for N_alliances = 1:3
  68.         alliance = container{N_alliances};
  69.         for j = 1:length(alliance)
  70.             filterpax = sum(cell2mat(filter(strcmp(filter(:,3),alliance{j}),4)));
  71.             pax = filterpax + pax;
  72.         end
  73.         switch N_alliances
  74.             case 1
  75.                 starpax = pax;
  76.                 nonstarpax = totalpax-starpax;
  77.             case 2
  78.                 oneworldpax = pax;
  79.                 non1wpax = totalpax - oneworldpax;
  80.             case 3
  81.                 skyteampax = pax;
  82.                 nonskypax = totalpax - skyteampax;
  83.         end
  84.         pax = 0;
  85.     end
  86.    
  87.     %% Assignment
  88.     uniqueZIPs{i,2} = AP_ORDpax;
  89.     uniqueZIPs{i,3} = AP_nonORDpax;
  90.     uniqueZIPs{i,4} = AP_DTWpax;
  91.     uniqueZIPs{i,5} = AP_nonDTWpax;
  92.     uniqueZIPs{i,6} = AP_MSPpax;
  93.     uniqueZIPs{i,7} = AP_nonMSPpax;    
  94.     uniqueZIPs{i,8} = AL_AApax;
  95.     uniqueZIPs{i,9} = AL_nonAApax;
  96.     uniqueZIPs{i,10} = AL_DLpax;
  97.     uniqueZIPs{i,11} = AL_nonDLpax;
  98.     uniqueZIPs{i,12} = AL_UApax;
  99.     uniqueZIPs{i,13} = AL_nonUApax;
  100.     uniqueZIPs{i,14} = AL_USpax;
  101.     uniqueZIPs{i,15} = AL_nonUSpax;
  102.     uniqueZIPs{i,16} = AP_AAUAPax;
  103.     uniqueZIPs{i,17} = AP_xAAUAPax;
  104.     uniqueZIPs{i,18} = HUB;
  105.     uniqueZIPs{i,19} = nonhub;
  106.    
  107. %     alliances
  108.     uniqueZIPs{i,20} = starpax;
  109.     uniqueZIPs{i,21} = nonstarpax;
  110.     uniqueZIPs{i,22} = skyteampax;
  111.     uniqueZIPs{i,23} = nonskypax;
  112.     uniqueZIPs{i,24} = oneworldpax;
  113.     uniqueZIPs{i,25} = non1wpax;
  114.  
  115.  
  116.     uniqueZIPs{i,26} = totalpax;
  117.    
  118. end
  119.  
  120.  
  121. T = cell2table(uniqueZIPs,'VariableNames',{'ZIP','ORD','notORD',...
  122.     'DTW','notDTW','MSP','notMSP','AApax','notAApax','DLpax','notDLpax',...
  123.     'UApax','notUApax','USpax','notUSpax',...
  124.     'ChicagoHubpax','NotChicagoHubpax','Hubpax','nothubpax',...
  125.     'StarAlliancepax','nonStarpax','skyteampax','nonskypax',...
  126.     'oneworldpax','non1wpax','totalpax'});
  127.  
  128. writetable(T,'midwestpaxdiff.csv')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top