Group By


In [1]:
import pandas as pd

In [5]:
data = pd.read_csv('data/fortune1000.csv', index_col='Rank')
data.head()


Out[5]:
Company Sector Industry Location Revenue Profits Employees
Rank
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
2 Exxon Mobil Energy Petroleum Refining Irving, TX 246204 16150 75600
3 Apple Technology Computers, Office Equipment Cupertino, CA 233715 53394 110000
4 Berkshire Hathaway Financials Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
5 McKesson Health Care Wholesalers: Health Care San Francisco, CA 181241 1476 70400

In [11]:
sectors = data.groupby('Sector') # creating a DataFrameGroupBy object

In [12]:
sectors.head()


Out[12]:
Company Sector Industry Location Revenue Profits Employees
Rank
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
2 Exxon Mobil Energy Petroleum Refining Irving, TX 246204 16150 75600
3 Apple Technology Computers, Office Equipment Cupertino, CA 233715 53394 110000
4 Berkshire Hathaway Financials Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
5 McKesson Health Care Wholesalers: Health Care San Francisco, CA 181241 1476 70400
6 UnitedHealth Group Health Care Health Care: Insurance and Managed Care Minnetonka, MN 157107 5813 200000
7 CVS Health Food and Drug Stores Food and Drug Stores Woonsocket, RI 153290 5237 199000
8 General Motors Motor Vehicles & Parts Motor Vehicles and Parts Detroit, MI 152356 9687 215000
9 Ford Motor Motor Vehicles & Parts Motor Vehicles and Parts Dearborn, MI 149558 7373 199000
10 AT&T Telecommunications Telecommunications Dallas, TX 146801 13345 281450
11 General Electric Industrials Industrial Machinery Fairfield, CT 140389 -6126 333000
12 AmerisourceBergen Health Care Wholesalers: Health Care Chesterbrook, PA 135962 -135 17000
13 Verizon Telecommunications Telecommunications New York, NY 131620 17879 177700
14 Chevron Energy Petroleum Refining San Ramon, CA 131118 4587 61500
15 Costco Retailing Specialty Retailers: Other Issaquah, WA 116199 2377 161000
16 Fannie Mae Financials Diversified Financials Washington, DC 110359 10954 7300
17 Kroger Food and Drug Stores Food and Drug Stores Cincinnati, OH 109830 2039 431000
18 Amazon.com Technology Internet Services and Retailing Seattle, WA 107006 596 230800
19 Walgreens Boots Alliance Food and Drug Stores Food and Drug Stores Deerfield, IL 103444 4220 302500
20 HP Technology Computers, Office Equipment Palo Alto, CA 103355 4554 287000
21 Cardinal Health Health Care Wholesalers: Health Care Dublin, OH 102531 1215 34500
22 Express Scripts Holding Health Care Health Care: Pharmacy and Other Services St. Louis, MO 101752 2476 25900
23 J.P. Morgan Chase Financials Commercial Banks New York, NY 101006 24442 234598
24 Boeing Aerospace & Defense Aerospace and Defense Chicago, IL 96114 5176 161400
25 Microsoft Technology Computer Software Redmond, WA 93580 12193 118000
26 Bank of America Corp. Financials Commercial Banks Charlotte, NC 93056 15888 213280
27 Wells Fargo Financials Commercial Banks San Francisco, CA 90033 22894 264700
28 Home Depot Retailing Specialty Retailers: Other Atlanta, GA 88519 7009 385000
30 Phillips 66 Energy Petroleum Refining Houston, TX 87169 4227 14000
31 IBM Technology Information Technology Services Armonk, NY 82461 13190 411798
... ... ... ... ... ... ... ...
151 Kimberly-Clark Household Products Household and Personal Products Irving, TX 18591 1013 43000
154 Lear Motor Vehicles & Parts Motor Vehicles and Parts Southfield, MI 18211 746 136200
155 Fluor Engineering & Construction Engineering, Construction Irving, TX 18114 413 38758
156 AECOM Engineering & Construction Engineering, Construction Los Angeles, CA 17990 -155 92000
159 CenturyLink Telecommunications Telecommunications Monroe, LA 17900 878 43000
170 Nucor Materials Metals Charlotte, NC 16439 358 23700
174 Colgate-Palmolive Household Products Household and Personal Products New York, NY 16034 1384 37900
182 PPG Industries Chemicals Chemicals Pittsburgh, PA 15330 1406 46600
186 Omnicom Group Business Services Advertising, marketing New York, NY 15134 1094 74900
189 Monsanto Chemicals Chemicals St. Louis, MO 15001 2314 24000
195 Marriott International Hotels, Resturants & Leisure Hotels, Casinos, Resorts Bethesda, MD 14486 859 127500
199 Aramark Business Services Diversified Outsourcing Services Philadelphia, PA 14329 236 216500
203 CBS Media Entertainment New York, NY 13886 1413 19080
204 Visa Business Services Financial Data Services Foster City, CA 13880 6328 11300
206 Ecolab Chemicals Chemicals St. Paul, MN 13545 1002 47145
213 Viacom Media Entertainment New York, NY 13268 1922 9445
218 Yum Brands Hotels, Resturants & Leisure Food Services Louisville, KY 13105 1293 505000
221 Waste Management Business Services Waste Management Houston, TX 12961 753 40600
231 VF Apparel Apparel Greensboro, NC 12377 1232 64000
235 Jacobs Engineering Group Engineering & Construction Engineering, Construction Pasadena, CA 12115 303 56950
241 Las Vegas Sands Hotels, Resturants & Leisure Hotels, Casinos, Resorts Las Vegas, NV 11689 1966 46500
244 United States Steel Materials Metals Pittsburgh, PA 11574 -1642 33200
251 WestRock Materials Packaging, Containers Richmond, VA 11381 507 41400
256 Stanley Black & Decker Household Products Home Equipment, Furnishings New Britain, CT 11211 884 51250
260 D.R. Horton Engineering & Construction Homebuilders Fort Worth, TX 10824 751 6230
261 Estee Lauder Household Products Household and Personal Products New York, NY 10780 1089 44000
301 Lennar Engineering & Construction Homebuilders Miami, FL 9474 803 7749
340 PVH Apparel Apparel New York, NY 8020 572 26200
354 Ralph Lauren Apparel Apparel New York, NY 7620 702 20000
448 Hanesbrands Apparel Apparel Winston-Salem, NC 5732 429 65300

105 rows × 7 columns


In [13]:
data.head()


Out[13]:
Company Sector Industry Location Revenue Profits Employees
Rank
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
2 Exxon Mobil Energy Petroleum Refining Irving, TX 246204 16150 75600
3 Apple Technology Computers, Office Equipment Cupertino, CA 233715 53394 110000
4 Berkshire Hathaway Financials Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
5 McKesson Health Care Wholesalers: Health Care San Francisco, CA 181241 1476 70400

In [14]:
print type(data)
print type(sectors)


<class 'pandas.core.frame.DataFrame'>
<class 'pandas.core.groupby.DataFrameGroupBy'>

In [16]:
print len(data)
print len(sectors) # data frame for each sector


1000
21

In [18]:
data['Sector'].nunique()


Out[18]:
21

In [22]:
sectors.size() # occurrences of each sector
# data['Sector'].value_counts()


Out[22]:
Sector
Aerospace & Defense              20
Apparel                          15
Business Services                51
Chemicals                        30
Energy                          122
Engineering & Construction       26
Financials                      139
Food and Drug Stores             15
Food, Beverages & Tobacco        43
Health Care                      75
Hotels, Resturants & Leisure     25
Household Products               28
Industrials                      46
Materials                        43
Media                            25
Motor Vehicles & Parts           24
Retailing                        80
Technology                      102
Telecommunications               15
Transportation                   36
Wholesalers                      40
dtype: int64

In [26]:
sectors.first() # first occurence of each grouping


Out[26]:
Company Industry Location Revenue Profits Employees
Sector
Aerospace & Defense Boeing Aerospace and Defense Chicago, IL 96114 5176 161400
Apparel Nike Apparel Beaverton, OR 30601 3273 62600
Business Services ManpowerGroup Temporary Help Milwaukee, WI 19330 419 27000
Chemicals Dow Chemical Chemicals Midland, MI 48778 7685 49495
Energy Exxon Mobil Petroleum Refining Irving, TX 246204 16150 75600
Engineering & Construction Fluor Engineering, Construction Irving, TX 18114 413 38758
Financials Berkshire Hathaway Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
Food and Drug Stores CVS Health Food and Drug Stores Woonsocket, RI 153290 5237 199000
Food, Beverages & Tobacco Archer Daniels Midland Food Production Chicago, IL 67702 1849 32300
Health Care McKesson Wholesalers: Health Care San Francisco, CA 181241 1476 70400
Hotels, Resturants & Leisure McDonald’s Food Services Oak Brook, IL 25413 4529 420000
Household Products Procter & Gamble Household and Personal Products Cincinnati, OH 78756 7036 110000
Industrials General Electric Industrial Machinery Fairfield, CT 140389 -6126 333000
Materials Alcoa Metals New York, NY 22534 -322 60000
Media Disney Entertainment Burbank, CA 52465 8382 185000
Motor Vehicles & Parts General Motors Motor Vehicles and Parts Detroit, MI 152356 9687 215000
Retailing Walmart General Merchandisers Bentonville, AR 482130 14694 2300000
Technology Apple Computers, Office Equipment Cupertino, CA 233715 53394 110000
Telecommunications AT&T Telecommunications Dallas, TX 146801 13345 281450
Transportation UPS Mail, Package, and Freight Delivery Atlanta, GA 58363 4844 341240
Wholesalers Sysco Wholesalers: Food and Grocery Houston, TX 48681 687 51700

In [27]:
sectors.last() # last occurence of each grouping


Out[27]:
Company Industry Location Revenue Profits Employees
Sector
Aerospace & Defense Delta Tucker Holdings Aerospace and Defense McLean, VA 1923 -133 12000
Apparel Guess Apparel Los Angeles, CA 2204 82 13500
Business Services DeVry Education Group Education Downers Grove, IL 1910 140 11770
Chemicals H.B. Fuller Chemicals St. Paul, MN 2084 87 4425
Energy Portland General Electric Utilities: Gas and Electric Portland, OR 1898 172 2646
Engineering & Construction MDC Holdings Homebuilders Denver, CO 1909 66 1225
Financials New York Community Bancorp Commercial Banks Westbury, NY 1902 -47 3448
Food and Drug Stores Fred’s Food and Drug Stores Memphis, TN 2151 -7 7103
Food, Beverages & Tobacco Alliance One International Tobacco Morrisville, NC 2066 -15 6835
Health Care Providence Service Health Care: Pharmacy and Other Services Tucson, AZ 1987 84 9072
Hotels, Resturants & Leisure Wendy’s Food Services Dublin, OH 1896 161 21200
Household Products Revlon Household and Personal Products New York, NY 1914 56 5700
Industrials Briggs & Stratton Industrial Machinery Wauwatosa, WI 1895 46 5480
Materials Schnitzer Steel Industries Metals Portland, OR 1924 -197 2955
Media Cenveo Publishing, Printing Stamford, CT 1921 -31 7300
Motor Vehicles & Parts Allison Transmission Holdings Motor Vehicles and Parts Indianaoplis, IN 1986 182 2700
Retailing 99 Cents Only Stores Specialty Retailers: Other Commerce, CA 1999 -232 18200
Technology F5 Networks Network and Other Communications Equipment Seattle, WA 1920 365 4178
Telecommunications Equinix Telecommunications Redwood City, CA 2726 188 5042
Transportation Roadrunner Transportation Systems Transportation and Logistics Cudahy, WI 1995 48 4502
Wholesalers BlueLinx Holdings Wholesalers: Diversified Atlanta, GA 1917 -12 1600

In [34]:
sectors.groups # Dict
# sectors.groups.keys() one key for each sector
# sectors.groups.values() List of Index


Out[34]:
{'Aerospace & Defense': Int64Index([ 24,  45,  60,  88, 118, 120, 209, 245, 282, 378, 389, 490, 560,
             605, 785, 788, 836, 903, 958, 987],
            dtype='int64', name=u'Rank'),
 'Apparel': Int64Index([91, 231, 340, 354, 448, 547, 575, 597, 683, 695, 726, 794, 877,
             882, 917],
            dtype='int64', name=u'Rank'),
 'Business Services': Int64Index([144, 186, 199, 204, 221, 248, 249, 294, 307, 312, 355, 392, 404,
             440, 467, 468, 481, 485, 492, 503, 545, 626, 635, 652, 677, 694,
             714, 729, 734, 735, 737, 744, 767, 776, 777, 783, 791, 792, 796,
             801, 803, 816, 819, 820, 869, 870, 886, 939, 951, 952, 993],
            dtype='int64', name=u'Rank'),
 'Chemicals': Int64Index([ 56, 101, 182, 189, 206, 253, 262, 277, 288, 296, 316, 538, 549,
             555, 566, 580, 613, 624, 654, 668, 717, 720, 724, 758, 761, 829,
             865, 898, 934, 949],
            dtype='int64', name=u'Rank'),
 'Energy': Int64Index([  2,  14,  30,  32,  42,  65,  90,  95,  98, 104,
             ...
             953, 955, 962, 966, 980, 981, 983, 995, 997, 997],
            dtype='int64', name=u'Rank', length=122),
 'Engineering & Construction': Int64Index([155, 156, 235, 260, 301, 314, 352, 381, 433, 478, 498, 501, 516,
             572, 576, 640, 719, 738, 822, 863, 874, 892, 929, 963, 985, 994],
            dtype='int64', name=u'Rank'),
 'Financials': Int64Index([  4,  16,  23,  26,  27,  29,  35,  40,  43,  49,
             ...
             920, 923, 925, 926, 936, 938, 959, 976, 988, 996],
            dtype='int64', name=u'Rank', length=139),
 'Food and Drug Stores': Int64Index([7, 17, 19, 87, 107, 160, 181, 595, 614, 631, 669, 756, 809, 849,
             928],
            dtype='int64', name=u'Rank'),
 'Food, Beverages & Tobacco': Int64Index([ 41,  44,  62,  66,  84,  94, 106, 149, 153, 161, 176, 207, 215,
             242, 266, 304, 336, 337, 362, 397, 413, 429, 452, 456, 460, 535,
             542, 567, 574, 587, 608, 615, 636, 664, 686, 702, 770, 787, 795,
             804, 889, 902, 954],
            dtype='int64', name=u'Rank'),
 'Health Care': Int64Index([  5,   6,  12,  21,  22,  33,  39,  46,  52,  55,  63,  72,  79,
              86, 123, 124, 125, 130, 138, 140, 141, 168, 172, 200, 201, 202,
             263, 268, 278, 286, 287, 290, 291, 305, 325, 358, 359, 372, 420,
             430, 431, 447, 457, 465, 469, 515, 527, 537, 553, 559, 583, 618,
             629, 661, 684, 693, 697, 708, 746, 749, 766, 775, 790, 799, 815,
             818, 845, 868, 881, 883, 935, 960, 965, 977, 978],
            dtype='int64', name=u'Rank'),
 'Hotels, Resturants & Leisure': Int64Index([109, 146, 195, 218, 241, 254, 309, 371, 444, 466, 534, 546, 557,
             562, 585, 731, 763, 764, 779, 797, 895, 915, 918, 941, 999],
            dtype='int64', name=u'Rank'),
 'Household Products': Int64Index([ 34, 151, 174, 256, 261, 328, 338, 345, 370, 434, 441, 450, 455,
             533, 550, 554, 601, 665, 699, 716, 856, 890, 900, 907, 932, 950,
             967, 992],
            dtype='int64', name=u'Rank'),
 'Industrials': Int64Index([  11,   59,   75,   93,   97,  128,  134,  148,  211,  224,  360,
              377,  396,  412,  419,  539,  544,  596,  622,  623,  630,  645,
              655,  658,  666,  674,  690,  757,  782,  789,  806,  813,  823,
              831,  832,  835,  841,  847,  866,  867,  873,  887,  942,  947,
              964, 1000],
            dtype='int64', name=u'Rank'),
 'Materials': Int64Index([126, 127, 170, 244, 251, 303, 321, 341, 356, 373, 375, 383, 417,
             418, 426, 435, 446, 480, 489, 514, 518, 577, 586, 616, 617, 620,
             625, 628, 637, 639, 641, 660, 667, 687, 691, 751, 774, 793, 857,
             885, 911, 982, 986],
            dtype='int64', name=u'Rank'),
 'Media': Int64Index([ 53,  96,  99, 203, 213, 255, 327, 366, 406, 414, 525, 530, 681,
             705, 707, 722, 741, 752, 759, 762, 821, 913, 968, 969, 989],
            dtype='int64', name=u'Rank'),
 'Motor Vehicles & Parts': Int64Index([  8,   9,  70, 147, 154, 169, 281, 310, 334, 339, 424, 428, 470,
             588, 591, 604, 647, 670, 718, 739, 811, 957, 961, 979],
            dtype='int64', name=u'Rank'),
 'Retailing': Int64Index([  1,  15,  28,  38,  47,  71,  89, 103, 111, 132, 136, 139, 143,
             145, 177, 180, 191, 196, 197, 228, 234, 237, 238, 240, 258, 267,
             269, 280, 293, 297, 299, 302, 330, 342, 346, 361, 365, 374, 379,
             380, 393, 415, 427, 439, 495, 500, 502, 511, 512, 517, 523, 582,
             592, 602, 607, 610, 621, 643, 644, 648, 657, 675, 689, 721, 748,
             771, 773, 807, 812, 824, 825, 827, 840, 876, 894, 899, 922, 937,
             940, 973],
            dtype='int64', name=u'Rank'),
 'Technology': Int64Index([  3,  18,  20,  25,  31,  36,  51,  54,  77, 110,
             ...
             931, 943, 944, 946, 956, 970, 971, 975, 984, 990],
            dtype='int64', name=u'Rank', length=102),
 'Telecommunications': Int64Index([10, 13, 37, 116, 159, 187, 292, 333, 399, 443, 461, 496, 526, 619,
             786],
            dtype='int64', name=u'Rank'),
 'Transportation': Int64Index([ 48,  58,  67,  68,  80, 129, 142, 208, 239, 270, 353, 390, 395,
             405, 407, 416, 432, 459, 521, 528, 570, 578, 642, 672, 709, 713,
             740, 800, 814, 858, 884, 930, 933, 945, 972, 974],
            dtype='int64', name=u'Rank'),
 'Wholesalers': Int64Index([ 57,  64,  92, 102, 108, 119, 122, 167, 183, 185, 212, 276, 285,
             315, 317, 320, 323, 335, 351, 357, 369, 391, 423, 463, 474, 477,
             484, 564, 581, 599, 627, 653, 685, 727, 747, 780, 808, 837, 875,
             991],
            dtype='int64', name=u'Rank')}

In [37]:
data.loc[24]


Out[37]:
Company                     Boeing
Sector         Aerospace & Defense
Industry     Aerospace and Defense
Location               Chicago, IL
Revenue                      96114
Profits                       5176
Employees                   161400
Name: 24, dtype: object

Get Group


In [40]:
sectors.get_group(name='Apparel') # return a dataframe


Out[40]:
Company Employees Industry Location Profits Revenue
Rank
91 Nike 62600 Apparel Beaverton, OR 3273 30601
231 VF 64000 Apparel Greensboro, NC 1232 12377
340 PVH 26200 Apparel New York, NY 572 8020
354 Ralph Lauren 20000 Apparel New York, NY 702 7620
448 Hanesbrands 65300 Apparel Winston-Salem, NC 429 5732
547 Levi Strauss 12500 Apparel San Francisco, CA 209 4495
575 Coach 12950 Apparel New York, NY 402 4192
597 Under Armour 9600 Apparel Baltimore, MD 233 3963
683 Fossil Group 15100 Apparel Richardson, TX 221 3229
695 Skechers U.S.A. 6400 Apparel Manhattan Beach, CA 232 3159
726 Carter’s 16800 Apparel Atlanta, GA 238 3014
794 Wolverine World Wide 6550 Apparel Rockford, MI 123 2692
877 G-III Apparel Group 8919 Apparel New York, NY 114 2344
882 Columbia Sportswear 5978 Apparel Portland, OR 174 2326
917 Guess 13500 Apparel Los Angeles, CA 82 2204

In [43]:
sectors.get_group(name='Energy')


Out[43]:
Company Employees Industry Location Profits Revenue
Rank
2 Exxon Mobil 75600 Petroleum Refining Irving, TX 16150 246204
14 Chevron 61500 Petroleum Refining San Ramon, CA 4587 131118
30 Phillips 66 14000 Petroleum Refining Houston, TX 4227 87169
32 Valero Energy 10103 Petroleum Refining San Antonio, TX 3990 81824
42 Marathon Petroleum 45440 Petroleum Refining Findlay, OH 2852 64566
65 Energy Transfer Equity 30078 Pipelines Dallas, TX 1189 42126
90 ConocoPhillips 15900 Mining, Crude-Oil Production Houston, TX -4428 30935
95 Exelon 29762 Utilities: Gas and Electric Chicago, IL 2269 29447
98 Tesoro 6016 Petroleum Refining San Antonio, TX 1540 28150
104 Enterprise Products Partners 6800 Pipelines Houston, TX 2521 27028
115 Duke Energy 29188 Utilities: Gas and Electric Charlotte, NC 2816 24002
117 Halliburton 65000 Oil and Gas Equipment, Services Houston, TX -671 23633
121 Plains GP Holdings 5400 Pipelines Houston, TX 118 23152
162 Southern 26703 Utilities: Gas and Electric Atlanta, GA 2367 17489
163 NextEra Energy 14300 Utilities: Gas and Electric Juno Beach, FL 2752 17486
165 American Electric Power 17405 Utilities: Gas and Electric Columbus, OH 2047 16900
166 PG&E Corp. 23323 Utilities: Gas and Electric San Francisco, CA 874 16833
175 Freeport-McMoRan 34500 Mining, Crude-Oil Production Phoenix, AZ -12236 15877
178 Baker Hughes 43000 Oil and Gas Equipment, Services Houston, TX -1967 15742
188 FirstEnergy 15781 Utilities: Gas and Electric Akron, OH 578 15026
190 AES 21000 Utilities: Gas and Electric Arlington, VA 306 14963
192 National Oilwell Varco 47262 Oil and Gas Equipment, Services Houston, TX -769 14757
193 NRG Energy 10468 Energy Princeton, NJ -6382 14674
198 Kinder Morgan 11290 Pipelines Houston, TX 253 14403
214 HollyFrontier 2704 Petroleum Refining Dallas, TX 740 13238
216 Devon Energy 5167 Mining, Crude-Oil Production Oklahoma City, OK -14454 13145
217 PBF Energy 2270 Petroleum Refining Parsippany, NJ 146 13124
223 Chesapeake Energy 4400 Mining, Crude-Oil Production Oklahoma City, OK -14685 12764
225 Occidental Petroleum 11100 Mining, Crude-Oil Production Houston, TX -7829 12699
229 Consolidated Edison 14806 Utilities: Gas and Electric New York, NY 1193 12554
... ... ... ... ... ... ...
784 New Jersey Resources 991 Energy Wall, NJ 181 2734
798 Continental Resources 1143 Mining, Crude-Oil Production Oklahoma City, OK -354 2680
802 WGL Holdings 1529 Energy Washington, DC 131 2660
810 Crestwood Equity Partners 1300 Energy Houston, TX -1667 2633
817 Hawaiian Electric Industries 3918 Utilities: Gas and Electric Honolulu, HI 160 2603
826 Arch Coal 4655 Mining, Crude-Oil Production St. Louis, MO -2913 2573
843 Great Plains Energy 2899 Utilities: Gas and Electric Kansas City, MO 213 2502
850 United Refining 2997 Petroleum Refining Warren, PA 82 2470
851 Southwest Gas 5876 Utilities: Gas and Electric Las Vegas, NV 138 2464
853 Westar Energy 2330 Utilities: Gas and Electric Topeka, KS 292 2459
855 Vectren 5600 Utilities: Gas and Electric Evansville, IN 197 2435
859 Enable Midstream Partners 1640 Pipelines Oklahoma City, OK -752 2418
860 Cliffs Natural Resources 2638 Mining, Crude-Oil Production Cleveland, OH -749 2418
862 California Resources 1700 Mining, Crude-Oil Production Los Angeles, CA -3554 2403
879 EQT 1914 Energy Pittsburgh, PA 85 2340
901 Alliance Holdings 4243 Mining, Crude-Oil Production Tulsa, OK 211 2273
908 Genesis Energy 1400 Pipelines Houston, TX 423 2247
921 OGE Energy 2586 Utilities: Gas and Electric Oklahoma City, OK 271 2197
924 Magellan Midstream Partners 1640 Pipelines Tulsa, OK 819 2189
948 NuStar Energy 1644 Pipelines San Antonio, TX 307 2084
953 Par Pacific Holdings 744 Petroleum Refining Houston, TX -40 2066
955 Whiting Petroleum 1200 Mining, Crude-Oil Production Denver, CO -2219 2051
962 Ferrellgas Partners 4028 Energy Overland Park, KS 30 2024
966 QEP Resources 693 Mining, Crude-Oil Production Denver, CO -149 2019
980 Spire 3078 Utilities: Gas and Electric St. Louis, MO 137 1976
981 WPX Energy 1040 Mining, Crude-Oil Production Tulsa, OK -1727 1958
983 Adams Resources & Energy 809 Petroleum Refining Houston, TX -1 1944
995 EP Energy 665 Mining, Crude-Oil Production Houston, TX -3748 1908
997 Portland General Electric 2646 Utilities: Gas and Electric Portland, OR 172 1898
997 Portland General Electric 2646 Utilities: Gas and Electric Portland, OR 172 1898

122 rows × 6 columns


In [45]:
for g in sectors.groups.keys():
    print "Group: {}".format(g), sectors.get_group(g)


Group: Household Products                              Company  Employees  \
Rank                                              
34                  Procter & Gamble     110000   
151                   Kimberly-Clark      43000   
174                Colgate-Palmolive      37900   
256           Stanley Black & Decker      51250   
261                     Estee Lauder      44000   
328                           Jarden      40000   
338                Mohawk Industries      34100   
345                            Masco      25000   
370                    Avon Products      30900   
434                    Newell Brands      17200   
441                        HRG Group      15922   
450                           Mattel      31000   
455                           Clorox       7700   
533   Fortune Brands Home & Security      21400   
550                           Hasbro       5000   
554                             Coty       8100   
601                  Leggett & Platt      20000   
665                  Church & Dwight       4406   
699       Tempur Sealy International       7200   
716                        Steelcase      11550   
856           Edgewell Personal Care       6000   
890                              HNI      10200   
900                Tupperware Brands      13000   
907              Nu Skin Enterprises      26800   
932                    Herman Miller       7510   
950                    Vista Outdoor       5200   
967                          Griffon       6000   
992                           Revlon       5700   

                             Industry          Location  Profits  Revenue  
Rank                                                                       
34    Household and Personal Products    Cincinnati, OH     7036    78756  
151   Household and Personal Products        Irving, TX     1013    18591  
174   Household and Personal Products      New York, NY     1384    16034  
256       Home Equipment, Furnishings   New Britain, CT      884    11211  
261   Household and Personal Products      New York, NY     1089    10780  
328       Home Equipment, Furnishings    Boca Raton, FL      147     8604  
338       Home Equipment, Furnishings       Calhoun, GA      615     8072  
345       Home Equipment, Furnishings        Taylor, MI      355     7904  
370   Household and Personal Products      New York, NY    -1149     7173  
434       Home Equipment, Furnishings       Atlanta, GA      350     5972  
441   Household and Personal Products      New York, NY     -557     5816  
450                     Miscellaneous    El Segundo, CA      369     5703  
455   Household and Personal Products       Oakland, CA      580     5666  
533       Home Equipment, Furnishings     Deerfield, IL      315     4658  
550                     Miscellaneous     Pawtucket, RI      452     4448  
554   Household and Personal Products      New York, NY      233     4395  
601       Home Equipment, Furnishings      Carthage, MO      325     3937  
665   Household and Personal Products         Ewing, NJ      410     3395  
699       Home Equipment, Furnishings     Lexington, KY       74     3151  
716       Home Equipment, Furnishings  Grand Rapids, MI       86     3060  
856   Household and Personal Products  Chesterfield, MO     -275     2421  
890       Home Equipment, Furnishings     Muscatine, IA      105     2304  
900   Household and Personal Products       Orlando, FL      186     2284  
907   Household and Personal Products         Provo, UT      133     2247  
932       Home Equipment, Furnishings       Zeeland, MI       98     2142  
950                     Miscellaneous    Clearfield, UT       80     2083  
967       Home Equipment, Furnishings      New York, NY       34     2016  
992   Household and Personal Products      New York, NY       56     1914  
Group: Transportation                                      Company  Employees  \
Rank                                                      
48                                       UPS     341240   
58                                     FedEx     323035   
67                   American Airlines Group     118500   
68                           Delta Air Lines      82949   
80               United Continental Holdings      84000   
129                            Union Pacific      47457   
142                       Southwest Airlines      49583   
208                  C.H. Robinson Worldwide      13159   
239                                      CSX      29761   
270                         Norfolk Southern      30456   
353                            XPO Logistics      89000   
390   Expeditors International of Washington      15397   
395                             Ryder System      33100   
405                          JetBlue Airways      14537   
407                       Trinity Industries      22030   
416             J.B. Hunt Transport Services      21562   
432                          Harley-Davidson       6300   
459                         Alaska Air Group      13858   
521                            YRC Worldwide      32000   
528                       Polaris Industries       8100   
570                     Swift Transportation      20900   
578                                Brunswick      12607   
642                                Hub Group       2633   
672                          Landstar System       1223   
709                                  SkyWest      18300   
713                                   Amerco      18415   
740                Old Dominion Freight Line      17931   
800                                  ArcBest      13000   
814                          Greenbrier Cos.      10689   
858                     Kansas City Southern       6670   
884                        Hawaiian Holdings       5548   
930                                    Kirby       4200   
933                          Spirit Airlines       4326   
945                       Werner Enterprises      12325   
972                        Genesee & Wyoming       7500   
974        Roadrunner Transportation Systems       4502   

                                 Industry              Location  Profits  \
Rank                                                                       
48    Mail, Package, and Freight Delivery           Atlanta, GA     4844   
58    Mail, Package, and Freight Delivery           Memphis, TN     1050   
67                               Airlines        Fort Worth, TX     7610   
68                               Airlines           Atlanta, GA     4526   
80                               Airlines           Chicago, IL     7340   
129                             Railroads             Omaha, NE     4772   
142                              Airlines            Dallas, TX     2181   
208          Transportation and Logistics      Eden Prairie, MN      510   
239                             Railroads      Jacksonville, FL     1968   
270                             Railroads           Norfolk, VA     1556   
353          Transportation and Logistics         Greenwich, CT     -191   
390          Transportation and Logistics           Seattle, WA      457   
395               Trucking, Truck Leasing             Miami, FL      305   
405                              Airlines  Long Island City, NY      677   
407              Transportation Equipment            Dallas, TX      797   
416               Trucking, Truck Leasing            Lowell, AR      427   
432              Transportation Equipment         Milwaukee, WI      752   
459                              Airlines           Seattle, WA      848   
521               Trucking, Truck Leasing     Overland Park, KS        1   
528              Transportation Equipment            Medina, MN      455   
570               Trucking, Truck Leasing           Phoenix, AZ      198   
578              Transportation Equipment       Lake Forest, IL      241   
642          Transportation and Logistics         Oak Brook, IL       71   
672               Trucking, Truck Leasing      Jacksonville, FL      148   
709                              Airlines        St. George, UT      118   
713               Trucking, Truck Leasing              Reno, NV      357   
740               Trucking, Truck Leasing       Thomasville, NC      305   
800               Trucking, Truck Leasing        Fort Smith, AR       45   
814              Transportation Equipment       Lake Oswego, OR      193   
858                             Railroads       Kansas City, MO      484   
884                              Airlines          Honolulu, HI      183   
930                         Miscellaneous           Houston, TX      227   
933                              Airlines           Miramar, FL      317   
945               Trucking, Truck Leasing             Omaha, NE      124   
972                             Railroads            Darien, CT      225   
974          Transportation and Logistics            Cudahy, WI       48   

      Revenue  
Rank           
48      58363  
58      47453  
67      40990  
68      40704  
80      37864  
129     21813  
142     19820  
208     13476  
239     11811  
270     10511  
353      7623  
390      6617  
395      6572  
405      6416  
407      6393  
416      6188  
432      5995  
459      5598  
521      4832  
528      4719  
570      4229  
578      4143  
642      3526  
672      3321  
709      3096  
713      3075  
740      2972  
800      2667  
814      2605  
858      2419  
884      2318  
930      2148  
933      2142  
945      2094  
972      2000  
974      1995  
Group: Business Services                                      Company  Employees  \
Rank                                                      
144                            ManpowerGroup      27000   
186                            Omnicom Group      74900   
199                                  Aramark     216500   
204                                     Visa      11300   
221                         Waste Management      40600   
248                                      ADP      55000   
249                               First Data      24000   
294                               MasterCard      11300   
307                          PayPal Holdings      16800   
312                        Republic Services      33000   
355                        Interpublic Group      49200   
392   Fidelity National Information Services      55000   
404                    Alliance Data Systems      16000   
440                           United Rentals      12700   
467                           Kelly Services       8100   
468                            Western Union      10000   
481                               S&P Global      20400   
485                           ABM Industries     120000   
492                                   Fiserv      22000   
503                Robert Half International      16100   
545                                   Cintas      32000   
626                            Towers Watson      16300   
635                                      ADT      17100   
652                                  Moody’s      10400   
677                            Clean Harbors      12900   
694                                   Vantiv       3313   
714                                  Brink’s      59900   
729                            Iron Mountain      20000   
734              Service Corp. International      19720   
735                               Stericycle      25472   
737                          Graham Holdings      11585   
744                                Convergys     130000   
767                              DST Systems      13420   
776                    Total System Services      10500   
777                          Global Payments       4438   
783                                  Paychex      13000   
791                                 TrueBlue       5500   
792           Broadridge Financial Solutions       7400   
796                Heartland Payment Systems       4272   
801                                  Equifax       8000   
803                             TriNet Group       2500   
816                                Insperity       2400   
819            ServiceMaster Global Holdings      13000   
820                   Apollo Education Group      23400   
869                                     West      10630   
870                           Public Storage       5300   
886                               IHS Markit       8600   
939                        Waste Connections       7227   
951                            On Assignment       3320   
952                         Verisk Analytics       7783   
993                    DeVry Education Group      11770   

                              Industry             Location  Profits  Revenue  
Rank                                                                           
144                     Temporary Help        Milwaukee, WI      419    19330  
186             Advertising, marketing         New York, NY     1094    15134  
199   Diversified Outsourcing Services     Philadelphia, PA      236    14329  
204            Financial Data Services      Foster City, CA     6328    13880  
221                   Waste Management          Houston, TX      753    12961  
248   Diversified Outsourcing Services         Roseland, NJ     1453    11477  
249            Financial Data Services          Atlanta, GA    -1481    11451  
294            Financial Data Services         Purchase, NY     3808     9667  
307            Financial Data Services         San Jose, CA     1228     9248  
312                   Waste Management          Phoenix, AZ      750     9115  
355             Advertising, marketing         New York, NY      455     7614  
392            Financial Data Services     Jacksonville, FL      632     6595  
404            Financial Data Services            Plano, TX      597     6440  
440                      Miscellaneous         Stamford, CT      585     5817  
467                     Temporary Help             Troy, MI       54     5518  
468            Financial Data Services        Englewood, CO      838     5484  
481            Financial Data Services         New York, NY     1156     5313  
485   Diversified Outsourcing Services         New York, NY       76     5291  
492            Financial Data Services       Brookfield, WI      712     5254  
503                     Temporary Help       Menlo Park, CA      358     5095  
545   Diversified Outsourcing Services       Cincinnati, OH      431     4508  
626   Diversified Outsourcing Services        Arlington, VA      385     3645  
635   Diversified Outsourcing Services       Boca Raton, FL      296     3574  
652            Financial Data Services         New York, NY      941     3485  
677                   Waste Management          Norwell, MA       44     3275  
694            Financial Data Services  Symmes Township, OH      148     3160  
714   Diversified Outsourcing Services         Richmond, VA      -12     3066  
729   Diversified Outsourcing Services           Boston, MA      123     3008  
734                      Miscellaneous          Houston, TX      234     2986  
735                   Waste Management      Lake Forest, IL      267     2986  
737                          Education        Arlington, VA     -101     2984  
744   Diversified Outsourcing Services       Cincinnati, OH      169     2951  
767            Financial Data Services      Kansas City, MO      358     2825  
776            Financial Data Services         Columbus, GA      364     2780  
777            Financial Data Services          Atlanta, GA      278     2774  
783   Diversified Outsourcing Services        Rochester, NY      675     2740  
791                     Temporary Help           Tacoma, WA       71     2696  
792            Financial Data Services     Lake Success, NY      287     2694  
796            Financial Data Services        Princeton, NJ       85     2682  
801            Financial Data Services          Atlanta, GA      429     2664  
803   Diversified Outsourcing Services      San Leandro, CA       32     2659  
816   Diversified Outsourcing Services         Kingwood, TX       39     2604  
819   Diversified Outsourcing Services          Memphis, TN      160     2594  
820                          Education          Phoenix, AZ       30     2591  
869   Diversified Outsourcing Services            Omaha, NE      242     2383  
870                      Miscellaneous         Glendale, CA     1311     2382  
886            Financial Data Services        Englewood, CO      240     2314  
939                   Waste Management    The Woodlands, TX      -96     2117  
951                     Temporary Help        Calabasas, CA       98     2077  
952            Financial Data Services      Jersey City, NJ      508     2068  
993                          Education    Downers Grove, IL      140     1910  
Group: Chemicals                                  Company  Employees   Industry  \
Rank                                                             
56                          Dow Chemical      49495  Chemicals   
101                               DuPont      52000  Chemicals   
182                       PPG Industries      46600  Chemicals   
189                             Monsanto      24000  Chemicals   
206                               Ecolab      47145  Chemicals   
253                     Sherwin-Williams      40706  Chemicals   
262                              Praxair      26657  Chemicals   
277                             Huntsman      15000  Chemicals   
288             Air Products & Chemicals      19550  Chemicals   
296                     Eastman Chemical      15000  Chemicals   
316                               Mosaic       8900  Chemicals   
538                    RPM International      12864  Chemicals   
549                    Westlake Chemical       4225  Chemicals   
555                              Valspar      11130  Chemicals   
566               CF Industries Holdings       2850  Chemicals   
580                               Hexion       5100  Chemicals   
613                               Axiall       5830  Chemicals   
624                            Albemarle       6963  Chemicals   
654                                  FMC       6000  Chemicals   
668                              PolyOne       6900  Chemicals   
717                           W.R. Grace       6700  Chemicals   
720   International Flavors & Fragrances       6732  Chemicals   
724                   Scotts Miracle-Gro       7900  Chemicals   
758                                Cabot       4600  Chemicals   
761                                 Olin       6200  Chemicals   
829          Platform Specialty Products       8200  Chemicals   
865                          A. Schulman       5000  Chemicals   
898                         MPM Holdings       5000  Chemicals   
934                            NewMarket       1979  Chemicals   
949                          H.B. Fuller       4425  Chemicals   

                 Location  Profits  Revenue  
Rank                                         
56            Midland, MI     7685    48778  
101        Wilmington, DE     1953    27940  
182        Pittsburgh, PA     1406    15330  
189         St. Louis, MO     2314    15001  
206          St. Paul, MN     1002    13545  
253         Cleveland, OH     1054    11339  
262           Danbury, CT     1547    10776  
277     The Woodlands, TX       93    10299  
288         Allentown, PA     1278     9895  
296         Kingsport, TN      848     9648  
316          Plymouth, MN     1000     8895  
538            Medina, OH      240     4595  
549           Houston, TX      646     4463  
555       Minneapolis, MN      400     4393  
566         Deerfield, IL      700     4308  
580          Columbus, OH      -40     4140  
613           Atlanta, GA     -816     3787  
624       Baton Rouge, LA      335     3651  
654      Philadelphia, PA      489     3471  
668         Avon Lake, OH      145     3378  
717          Columbia, MD      144     3052  
720          New York, NY      419     3023  
724        Marysville, OH      160     3017  
758            Boston, MA     -334     2871  
761           Clayton, MO       -1     2854  
829   West Palm Beach, FL     -309     2542  
865          Fairlawn, OH       27     2392  
898         Waterford, NY      -83     2289  
934          Richmond, VA      239     2141  
949          St. Paul, MN       87     2084  
Group: Media                            Company  Employees              Industry  \
Rank                                                                  
53                          Disney     185000         Entertainment   
96        Twenty-First Century Fox      20500         Entertainment   
99                     Time Warner      24800         Entertainment   
203                            CBS      19080         Entertainment   
213                         Viacom       9445         Entertainment   
255          R.R. Donnelley & Sons      68400  Publishing, Printing   
327                     News Corp.      25000  Publishing, Printing   
366      Live Nation Entertainment      12200         Entertainment   
406       Discovery Communications       7000         Entertainment   
414                    iHeartMedia      18700         Entertainment   
525                  Liberty Media       3503         Entertainment   
530                  Quad/Graphics      22500  Publishing, Printing   
681                          TEGNA      10020         Entertainment   
705      Regal Entertainment Group      25915         Entertainment   
707                           Time       7200  Publishing, Printing   
722   Scripps Networks Interactive       3500         Entertainment   
741             Warner Music Group       4211         Entertainment   
752                        Gannett      18700  Publishing, Printing   
759       Univision Communications       3700         Entertainment   
762              Cinemark Holdings      17649         Entertainment   
821                   AMC Networks       2341         Entertainment   
913       Sinclair Broadcast Group       8000         Entertainment   
968             American Greetings      17650  Publishing, Printing   
969                  Tribune Media       8000         Entertainment   
989                         Cenveo       7300  Publishing, Printing   

               Location  Profits  Revenue  
Rank                                       
53          Burbank, CA     8382    52465  
96         New York, NY     8306    28987  
99         New York, NY     3833    28118  
203        New York, NY     1413    13886  
213        New York, NY     1922    13268  
255         Chicago, IL      151    11257  
327        New York, NY     -147     8633  
366   Beverly Hills, CA      -33     7246  
406   Silver Spring, MD     1034     6394  
414     San Antonio, TX     -755     6242  
525       Englewood, CO       64     4795  
530          Sussex, WI     -642     4678  
681          McLean, VA      460     3242  
705       Knoxville, TN      153     3127  
707        New York, NY     -881     3103  
722       Knoxville, TN      607     3018  
741        New York, NY      -91     2966  
752          McLean, VA      146     2885  
759        New York, NY      -45     2858  
762           Plano, TX      217     2853  
821        New York, NY      367     2581  
913     Hunt Valley, MD      172     2219  
968       Cleveland, OH       65     2011  
969         Chicago, IL     -320     2011  
989        Stamford, CT      -31     1921  
Group: Energy                            Company  Employees  \
Rank                                            
2                      Exxon Mobil      75600   
14                         Chevron      61500   
30                     Phillips 66      14000   
32                   Valero Energy      10103   
42              Marathon Petroleum      45440   
65          Energy Transfer Equity      30078   
90                  ConocoPhillips      15900   
95                          Exelon      29762   
98                          Tesoro       6016   
104   Enterprise Products Partners       6800   
115                    Duke Energy      29188   
117                    Halliburton      65000   
121             Plains GP Holdings       5400   
162                       Southern      26703   
163                 NextEra Energy      14300   
165        American Electric Power      17405   
166                     PG&E Corp.      23323   
175               Freeport-McMoRan      34500   
178                   Baker Hughes      43000   
188                    FirstEnergy      15781   
190                            AES      21000   
192         National Oilwell Varco      47262   
193                     NRG Energy      10468   
198                  Kinder Morgan      11290   
214                  HollyFrontier       2704   
216                   Devon Energy       5167   
217                     PBF Energy       2270   
223              Chesapeake Energy       4400   
225           Occidental Petroleum      11100   
229            Consolidated Edison      14806   
...                            ...        ...   
784           New Jersey Resources        991   
798          Continental Resources       1143   
802                   WGL Holdings       1529   
810      Crestwood Equity Partners       1300   
817   Hawaiian Electric Industries       3918   
826                      Arch Coal       4655   
843            Great Plains Energy       2899   
850                United Refining       2997   
851                  Southwest Gas       5876   
853                  Westar Energy       2330   
855                        Vectren       5600   
859      Enable Midstream Partners       1640   
860       Cliffs Natural Resources       2638   
862           California Resources       1700   
879                            EQT       1914   
901              Alliance Holdings       4243   
908                 Genesis Energy       1400   
921                     OGE Energy       2586   
924    Magellan Midstream Partners       1640   
948                  NuStar Energy       1644   
953           Par Pacific Holdings        744   
955              Whiting Petroleum       1200   
962            Ferrellgas Partners       4028   
966                  QEP Resources        693   
980                          Spire       3078   
981                     WPX Energy       1040   
983       Adams Resources & Energy        809   
995                      EP Energy        665   
997      Portland General Electric       2646   
997      Portland General Electric       2646   

                             Industry           Location  Profits  Revenue  
Rank                                                                        
2                  Petroleum Refining         Irving, TX    16150   246204  
14                 Petroleum Refining      San Ramon, CA     4587   131118  
30                 Petroleum Refining        Houston, TX     4227    87169  
32                 Petroleum Refining    San Antonio, TX     3990    81824  
42                 Petroleum Refining        Findlay, OH     2852    64566  
65                          Pipelines         Dallas, TX     1189    42126  
90       Mining, Crude-Oil Production        Houston, TX    -4428    30935  
95        Utilities: Gas and Electric        Chicago, IL     2269    29447  
98                 Petroleum Refining    San Antonio, TX     1540    28150  
104                         Pipelines        Houston, TX     2521    27028  
115       Utilities: Gas and Electric      Charlotte, NC     2816    24002  
117   Oil and Gas Equipment, Services        Houston, TX     -671    23633  
121                         Pipelines        Houston, TX      118    23152  
162       Utilities: Gas and Electric        Atlanta, GA     2367    17489  
163       Utilities: Gas and Electric     Juno Beach, FL     2752    17486  
165       Utilities: Gas and Electric       Columbus, OH     2047    16900  
166       Utilities: Gas and Electric  San Francisco, CA      874    16833  
175      Mining, Crude-Oil Production        Phoenix, AZ   -12236    15877  
178   Oil and Gas Equipment, Services        Houston, TX    -1967    15742  
188       Utilities: Gas and Electric          Akron, OH      578    15026  
190       Utilities: Gas and Electric      Arlington, VA      306    14963  
192   Oil and Gas Equipment, Services        Houston, TX     -769    14757  
193                            Energy      Princeton, NJ    -6382    14674  
198                         Pipelines        Houston, TX      253    14403  
214                Petroleum Refining         Dallas, TX      740    13238  
216      Mining, Crude-Oil Production  Oklahoma City, OK   -14454    13145  
217                Petroleum Refining     Parsippany, NJ      146    13124  
223      Mining, Crude-Oil Production  Oklahoma City, OK   -14685    12764  
225      Mining, Crude-Oil Production        Houston, TX    -7829    12699  
229       Utilities: Gas and Electric       New York, NY     1193    12554  
...                               ...                ...      ...      ...  
784                            Energy           Wall, NJ      181     2734  
798      Mining, Crude-Oil Production  Oklahoma City, OK     -354     2680  
802                            Energy     Washington, DC      131     2660  
810                            Energy        Houston, TX    -1667     2633  
817       Utilities: Gas and Electric       Honolulu, HI      160     2603  
826      Mining, Crude-Oil Production      St. Louis, MO    -2913     2573  
843       Utilities: Gas and Electric    Kansas City, MO      213     2502  
850                Petroleum Refining         Warren, PA       82     2470  
851       Utilities: Gas and Electric      Las Vegas, NV      138     2464  
853       Utilities: Gas and Electric         Topeka, KS      292     2459  
855       Utilities: Gas and Electric     Evansville, IN      197     2435  
859                         Pipelines  Oklahoma City, OK     -752     2418  
860      Mining, Crude-Oil Production      Cleveland, OH     -749     2418  
862      Mining, Crude-Oil Production    Los Angeles, CA    -3554     2403  
879                            Energy     Pittsburgh, PA       85     2340  
901      Mining, Crude-Oil Production          Tulsa, OK      211     2273  
908                         Pipelines        Houston, TX      423     2247  
921       Utilities: Gas and Electric  Oklahoma City, OK      271     2197  
924                         Pipelines          Tulsa, OK      819     2189  
948                         Pipelines    San Antonio, TX      307     2084  
953                Petroleum Refining        Houston, TX      -40     2066  
955      Mining, Crude-Oil Production         Denver, CO    -2219     2051  
962                            Energy  Overland Park, KS       30     2024  
966      Mining, Crude-Oil Production         Denver, CO     -149     2019  
980       Utilities: Gas and Electric      St. Louis, MO      137     1976  
981      Mining, Crude-Oil Production          Tulsa, OK    -1727     1958  
983                Petroleum Refining        Houston, TX       -1     1944  
995      Mining, Crude-Oil Production        Houston, TX    -3748     1908  
997       Utilities: Gas and Electric       Portland, OR      172     1898  
997       Utilities: Gas and Electric       Portland, OR      172     1898  

[122 rows x 6 columns]
Group: Food and Drug Stores                        Company  Employees              Industry  \
Rank                                                              
7                   CVS Health     199000  Food and Drug Stores   
17                      Kroger     431000  Food and Drug Stores   
19    Walgreens Boots Alliance     302500  Food and Drug Stores   
87        Publix Super Markets     180000  Food and Drug Stores   
107                   Rite Aid      69865  Food and Drug Stores   
160                  Supervalu      38500  Food and Drug Stores   
181         Whole Foods Market      76300  Food and Drug Stores   
595       Smart & Final Stores       6939  Food and Drug Stores   
614             Ingles Markets      17125  Food and Drug Stores   
631     Sprouts Farmers Market      20000  Food and Drug Stores   
669          Diplomat Pharmacy       1616  Food and Drug Stores   
756               Weis Markets      19000  Food and Drug Stores   
809               GNC Holdings      11650  Food and Drug Stores   
849               Tops Holding      14800  Food and Drug Stores   
928                     Fred’s       7103  Food and Drug Stores   

                Location  Profits  Revenue  
Rank                                        
7         Woonsocket, RI     5237   153290  
17        Cincinnati, OH     2039   109830  
19         Deerfield, IL     4220   103444  
87          Lakeland, FL     1965    32619  
107        Camp Hill, PA     2109    26528  
160     Eden Prairie, MN      192    17820  
181           Austin, TX      536    15389  
595         Commerce, CA       38     3971  
614   Black Mountain, NC       59     3779  
631          Phoenix, AZ      129     3593  
669            Flint, MI       26     3367  
756          Sunbury, PA       59     2877  
809       Pittsburgh, PA      219     2639  
849    Williamsville, NY      -62     2472  
928          Memphis, TN       -7     2151  
Group: Food, Beverages & Tobacco                           Company  Employees                Industry  \
Rank                                                                   
41         Archer Daniels Midland      32300         Food Production   
44                        PepsiCo     263000  Food Consumer Products   
62                      Coca-Cola     123200               Beverages   
66                    Tyson Foods     113000         Food Production   
84                            CHS      12511         Food Production   
94         Mondelez International      99000  Food Consumer Products   
106   Philip Morris International      80200                 Tobacco   
149                  Altria Group       8800                 Tobacco   
153                   Kraft Heinz      42000  Food Consumer Products   
161                 General Mills      42000  Food Consumer Products   
176                 ConAgra Foods      32900  Food Consumer Products   
207                       Kellogg      33577  Food Consumer Products   
215                  Land O’Lakes      10000  Food Consumer Products   
242             Leucadia National      13300         Food Production   
266             Reynolds American       5650                 Tobacco   
304                  Hormel Foods      20700  Food Consumer Products   
336                    Dean Foods      16960  Food Consumer Products   
337                 Campbell Soup      18600  Food Consumer Products   
362                       Hershey      19885  Food Consumer Products   
397   Coca-Cola European Partners      11500               Beverages   
413       Dr Pepper Snapple Group      19000               Beverages   
429          Constellation Brands       7200               Beverages   
452                  J.M. Smucker       7370  Food Consumer Products   
456                     Ingredion      11500         Food Production   
460                      Seaboard      10772         Food Production   
535                 Post Holdings       8500  Food Consumer Products   
542         Keurig Green Mountain       6000               Beverages   
567                     McCormick      10600  Food Consumer Products   
574                     Andersons       2954         Food Production   
587        Mead Johnson Nutrition       7660  Food Consumer Products   
608               WhiteWave Foods       5300  Food Consumer Products   
615                 Flowers Foods      10900  Food Consumer Products   
636          Molson Coors Brewing      17500               Beverages   
664           Darling Ingredients      10000         Food Production   
686               TreeHouse Foods       5880  Food Consumer Products   
702                  Brown-Forman       4300               Beverages   
770               Sanderson Farms      12264         Food Production   
787              Monster Beverage       1857               Beverages   
795          Hain Celestial Group       6307  Food Consumer Products   
804                Pinnacle Foods       4300  Food Consumer Products   
889            Coca-Cola Bottling       8550               Beverages   
902                     Universal      27000                 Tobacco   
954    Alliance One International       6835                 Tobacco   

                     Location  Profits  Revenue  
Rank                                             
41                Chicago, IL     1849    67702  
44               Purchase, NY     5452    63056  
62                Atlanta, GA     7351    44294  
66             Springdale, AR     1220    41373  
84    Inver Grove Heights, MN      781    34582  
94              Deerfield, IL     7267    29636  
106              New York, NY     6873    26794  
149              Richmond, VA     5241    18854  
153            Pittsburgh, PA      634    18338  
161           Minneapolis, MN     1221    17630  
176                 Omaha, NE     -253    15849  
207          Battle Creek, MI      614    13525  
215           Arden Hills, MN      308    13161  
242              New York, NY      284    11684  
266         Winston-Salem, NC     3253    10675  
304                Austin, MN      686     9264  
336                Dallas, TX       -9     8122  
337                Camden, NJ      691     8082  
362               Hershey, PA      513     7387  
397               Atlanta, GA      596     6540  
413                 Plano, TX      764     6282  
429                Victor, NY      839     6028  
452              Orrville, OH      345     5693  
456           Westchester, IL      402     5621  
460               Merriam, KS      171     5594  
535             St. Louis, MO     -115     4648  
542             Waterbury, VT      498     4520  
567                Sparks, MD      402     4296  
574                Maumee, OH      -13     4199  
587              Glenview, IL      654     4071  
608                Denver, CO      168     3866  
615           Thomasville, GA      189     3779  
636                Denver, CO      360     3568  
664                Irving, TX       79     3397  
686             Oak Brook, IL      115     3206  
702            Louisville, KY      684     3134  
770                Laurel, MS      216     2804  
787                Corona, CA      547     2723  
795          Lake Success, NY      168     2689  
804            Parsippany, NJ      213     2656  
889             Charlotte, NC       59     2307  
902              Richmond, VA      115     2272  
954           Morrisville, NC      -15     2066  
Group: Retailing                                Company  Employees  \
Rank                                                
1                              Walmart    2300000   
15                              Costco     161000   
28                          Home Depot     385000   
38                              Target     341000   
47                              Lowe’s     225000   
71                            Best Buy     125000   
89                                 TJX     216000   
103                             Macy’s     157500   
111                     Sears Holdings     178000   
132                            Staples      58963   
136                         AutoNation      26000   
139                     Dollar General     113400   
143            Penske Automotive Group      23000   
145                             Kohl’s      86000   
177                                Gap     141000   
180                        Dollar Tree     111550   
191                             CarMax      22064   
196                       Office Depot      49000   
197                          Nordstrom      72500   
228                        J.C. Penney     105000   
234                           L Brands      55400   
237                        Ross Stores      77800   
238                  Bed Bath & Beyond      60000   
240                        Toys “R” Us      62000   
258                         Murphy USA       7100   
267                 Group 1 Automotive      12886   
269              Hertz Global Holdings      30000   
280                           AutoZone      63990   
293                 Advance Auto Parts      56500   
297                   Sonic Automotive       9800   
...                                ...        ...   
523                Ascena Retail Group      31000   
582                            Tiffany      12200   
592                           Cabela’s      19700   
602   Ulta Salon Cosmetics & Fragrance      18100   
607                           Fastenal      20746   
610              Sally Beauty Holdings      21033   
621                                HSN       6600   
643          American Eagle Outfitters      22150   
644                Abercrombie & Fitch      28500   
648                    Tailored Brands      21250   
657                   Urban Outfitters      16680   
675                      Rent-A-Center      24300   
689                            Aaron’s      12700   
721                            Genesco      18363   
748                           Systemax       3300   
771                         PriceSmart       7592   
773                     Bon-Ton Stores      24100   
807                        Chico’s FAS      14755   
812                                DSW      11900   
824                            Caleres      11000   
825                      PC Connection       2155   
827              Mattress Firm Holding       7186   
840                       J.Crew Group      10450   
876                            Express      10710   
894                  Party City Holdco      12888   
899     Sears Hometown & Outlet Stores       2918   
922                          Outerwall       2670   
937                            hhgregg       4941   
940               Restoration Hardware       4200   
973               99 Cents Only Stores      18200   

                            Industry              Location  Profits  Revenue  
Rank                                                                          
1              General Merchandisers       Bentonville, AR    14694   482130  
15        Specialty Retailers: Other          Issaquah, WA     2377   116199  
28        Specialty Retailers: Other           Atlanta, GA     7009    88519  
38             General Merchandisers       Minneapolis, MN     3363    73785  
47        Specialty Retailers: Other       Mooresville, NC     2546    59074  
71        Specialty Retailers: Other         Richfield, MN      897    39745  
89      Specialty Retailers: Apparel        Framingham, MA     2278    30945  
103            General Merchandisers        Cincinnati, OH     1072    27079  
111            General Merchandisers   Hoffman Estates, IL    -1129    25146  
132       Specialty Retailers: Other        Framingham, MA      379    21059  
136   Automotive Retailing, Services   Fort Lauderdale, FL      443    20862  
139            General Merchandisers    Goodlettsville, TN     1165    20369  
143   Automotive Retailing, Services  Bloomfield Hills, MI      326    19361  
145            General Merchandisers   Menomonee Falls, WI      673    19204  
177     Specialty Retailers: Apparel     San Francisco, CA      920    15797  
180       Specialty Retailers: Other        Chesapeake, VA      282    15498  
191   Automotive Retailing, Services          Richmond, VA      597    14874  
196       Specialty Retailers: Other        Boca Raton, FL        8    14485  
197            General Merchandisers           Seattle, WA      600    14437  
228            General Merchandisers             Plano, TX     -513    12625  
234     Specialty Retailers: Apparel          Columbus, OH     1253    12154  
237     Specialty Retailers: Apparel            Dublin, CA     1021    11940  
238       Specialty Retailers: Other             Union, NJ      958    11881  
240       Specialty Retailers: Other             Wayne, NJ     -130    11802  
258       Specialty Retailers: Other         El Dorado, AR      176    10885  
267   Automotive Retailing, Services           Houston, TX       94    10633  
269   Automotive Retailing, Services            Estero, FL      273    10535  
280       Specialty Retailers: Other           Memphis, TN     1160    10187  
293       Specialty Retailers: Other           Roanoke, VA      473     9737  
297   Automotive Retailing, Services         Charlotte, NC       86     9624  
...                              ...                   ...      ...      ...  
523     Specialty Retailers: Apparel            Mahwah, NJ     -237     4803  
582       Specialty Retailers: Other          New York, NY      464     4105  
592       Specialty Retailers: Other            Sidney, NE      189     3998  
602       Specialty Retailers: Other       Bolingbrook, IL      320     3924  
607       Specialty Retailers: Other            Winona, MN      516     3869  
610       Specialty Retailers: Other            Denton, TX      235     3834  
621       Specialty Retailers: Other    St. Petersburg, FL      169     3691  
643     Specialty Retailers: Apparel        Pittsburgh, PA      218     3522  
644     Specialty Retailers: Apparel        New Albany, OH       36     3519  
648     Specialty Retailers: Apparel           Houston, TX    -1027     3496  
657     Specialty Retailers: Apparel      Philadelphia, PA      225     3445  
675       Specialty Retailers: Other             Plano, TX     -867     3278  
689       Specialty Retailers: Other           Atlanta, GA      136     3180  
721     Specialty Retailers: Apparel         Nashville, TN       95     3022  
748       Specialty Retailers: Other   Port Washington, NY     -100     2908  
771       Specialty Retailers: Other         San Diego, CA       89     2803  
773            General Merchandisers              York, PA      -57     2790  
807     Specialty Retailers: Apparel        Fort Myers, FL        2     2642  
812     Specialty Retailers: Apparel          Columbus, OH      136     2620  
824     Specialty Retailers: Apparel         St. Louis, MO       82     2577  
825       Specialty Retailers: Other         Merrimack, NH       47     2574  
827       Specialty Retailers: Other           Houston, TX       65     2547  
840     Specialty Retailers: Apparel          New York, NY    -1243     2506  
876     Specialty Retailers: Apparel          Columbus, OH      117     2350  
894       Specialty Retailers: Other          Elmsford, NY       11     2295  
899       Specialty Retailers: Other   Hoffman Estates, IL      -27     2288  
922       Specialty Retailers: Other          Bellevue, WA       44     2195  
937       Specialty Retailers: Other      Indianapolis, IN     -133     2129  
940       Specialty Retailers: Other      Corte Madera, CA       91     2109  
973       Specialty Retailers: Other          Commerce, CA     -232     1999  

[80 rows x 6 columns]
Group: Wholesalers                               Company  Employees  \
Rank                                               
57                              Sysco      51700   
64                       Ingram Micro      27700   
92                World Fuel Services       4700   
102                             Avnet      18800   
108                         Tech Data       9000   
119                 Arrow Electronics      18500   
122                  US Foods Holding      25000   
167               NGL Energy Partners       3100   
183                     Genuine Parts      39600   
185            Performance Food Group      12000   
212                            Synnex      78500   
276                   Global Partners       1890   
285                     W.W. Grainger      25100   
315                            Univar       9200   
317                 Core-Mark Holding       6655   
320                HD Supply Holdings      14000   
323                           Veritiv       8800   
335              United Natural Foods       8700   
351                       SpartanNash      11850   
357               WESCO International       9300   
369                               LKQ      31100   
391             Anixter International       8700   
423                  Graybar Electric       8300   
463               Lansing Trade Group        500   
474               Insight Enterprises       5761   
477                         Essendant       6400   
484                            Airgas      17000   
564                               VWR       9300   
581                            Watsco       5000   
599          Nexeo Solutions Holdings       2450   
627                     Boise Cascade       5830   
653                 Sprague Resources        590   
685                        ScanSource       2000   
727                               NOW       4850   
747             MSC Industrial Direct       6588   
780   Applied Industrial Technologies       5839   
808              Kar Auction Services      12528   
837             Beacon Roofing Supply       3366   
875                              Pool       3800   
991                 BlueLinx Holdings       1600   

                                           Industry                 Location  \
Rank                                                                           
57                    Wholesalers: Food and Grocery              Houston, TX   
64    Wholesalers: Electronics and Office Equipment               Irvine, CA   
92                         Wholesalers: Diversified                Miami, FL   
102   Wholesalers: Electronics and Office Equipment              Phoenix, AZ   
108   Wholesalers: Electronics and Office Equipment           Clearwater, FL   
119   Wholesalers: Electronics and Office Equipment           Centennial, CO   
122                   Wholesalers: Food and Grocery             Rosemont, IL   
167                        Wholesalers: Diversified                Tulsa, OK   
183                        Wholesalers: Diversified              Atlanta, GA   
185                   Wholesalers: Food and Grocery             Richmond, VA   
212   Wholesalers: Electronics and Office Equipment              Fremont, CA   
276                        Wholesalers: Diversified              Waltham, MA   
285                        Wholesalers: Diversified          Lake Forest, IL   
315                                   Miscellaneous        Downers Grove, IL   
317                   Wholesalers: Food and Grocery  South San Francisco, CA   
320                        Wholesalers: Diversified              Atlanta, GA   
323                        Wholesalers: Diversified              Atlanta, GA   
335                   Wholesalers: Food and Grocery           Providence, RI   
351                   Wholesalers: Food and Grocery         Byron Center, MI   
357                        Wholesalers: Diversified           Pittsburgh, PA   
369                        Wholesalers: Diversified              Chicago, IL   
391                        Wholesalers: Diversified             Glenview, IL   
423                        Wholesalers: Diversified            St. Louis, MO   
463                        Wholesalers: Diversified        Overland Park, KS   
474   Wholesalers: Electronics and Office Equipment                Tempe, AZ   
477   Wholesalers: Electronics and Office Equipment            Deerfield, IL   
484                        Wholesalers: Diversified               Radnor, PA   
564                        Wholesalers: Diversified               Radnor, PA   
581                        Wholesalers: Diversified                Miami, FL   
599                        Wholesalers: Diversified        The Woodlands, TX   
627                        Wholesalers: Diversified                Boise, ID   
653                        Wholesalers: Diversified           Portsmouth, NH   
685   Wholesalers: Electronics and Office Equipment           Greenville, SC   
727                        Wholesalers: Diversified              Houston, TX   
747                        Wholesalers: Diversified             Melville, NY   
780                        Wholesalers: Diversified            Cleveland, OH   
808                        Wholesalers: Diversified               Carmel, IN   
837                        Wholesalers: Diversified              Herndon, VA   
875                        Wholesalers: Diversified            Covington, LA   
991                        Wholesalers: Diversified              Atlanta, GA   

      Profits  Revenue  
Rank                    
57        687    48681  
64        215    43026  
92        187    30380  
102       572    27925  
108       266    26380  
119       498    23282  
122       168    23128  
167        17    16802  
183       706    15280  
185        57    15270  
212       209    13338  
276        44    10315  
285       769     9973  
315        17     8982  
317        52     8858  
320      1472     8779  
323        27     8718  
335       139     8185  
351        63     7652  
357       211     7519  
369       423     7193  
391       128     6596  
423        91     6110  
463        35     5565  
474        76     5373  
477       -44     5363  
484       368     5305  
564       154     4319  
581       173     4113  
599        20     3949  
627        52     3633  
653        78     3482  
685        65     3219  
727      -502     3010  
747       231     2910  
780       116     2752  
808       215     2640  
837        62     2515  
875       128     2363  
991       -12     1917  
Group: Engineering & Construction                        Company  Employees                   Industry  \
Rank                                                                   
155                      Fluor      38758  Engineering, Construction   
156                      AECOM      92000  Engineering, Construction   
235   Jacobs Engineering Group      56950  Engineering, Construction   
260                D.R. Horton       6230               Homebuilders   
301                     Lennar       7749               Homebuilders   
314         Peter Kiewit Sons’      22000  Engineering, Construction   
352            Quanta Services      24500  Engineering, Construction   
381                EMCOR Group      29000  Engineering, Construction   
433                 PulteGroup       4542               Homebuilders   
478                  CH2M Hill      22000  Engineering, Construction   
498                        NVR       4300               Homebuilders   
501                        KBR      22000  Engineering, Construction   
516               Tutor Perini      10626  Engineering, Construction   
572                     MasTec      15900  Engineering, Construction   
576              Toll Brothers       3900               Homebuilders   
640          CalAtlantic Group       2855               Homebuilders   
719                    KB Home       1680               Homebuilders   
738       Taylor Morrison Home       1600               Homebuilders   
822             Meritage Homes       1409               Homebuilders   
863           TRI Pointe Group       1036               Homebuilders   
874       Granite Construction       3200  Engineering, Construction   
892                 Tetra Tech      13000  Engineering, Construction   
929      Hovnanian Enterprises       2078               Homebuilders   
963           Dycom Industries      11159  Engineering, Construction   
985          Primoris Services       7011  Engineering, Construction   
994               MDC Holdings       1225               Homebuilders   

                    Location  Profits  Revenue  
Rank                                            
155               Irving, TX      413    18114  
156          Los Angeles, CA     -155    17990  
235             Pasadena, CA      303    12115  
260           Fort Worth, TX      751    10824  
301                Miami, FL      803     9474  
314                Omaha, NE      251     8992  
352              Houston, TX      311     7632  
381              Norwalk, CT      172     6723  
433              Atlanta, GA      494     5982  
478            Englewood, CO       80     5362  
498               Reston, VA      383     5170  
501              Houston, TX      203     5096  
516               Sylmar, CA       45     4921  
572         Coral Gables, FL      -79     4208  
576              Horsham, PA      363     4171  
640               Irvine, CA      214     3540  
719          Los Angeles, CA       85     3032  
738           Scottsdale, AZ       61     2977  
822           Scottsdale, AZ      129     2580  
863               Irvine, CA      206     2401  
874          Watsonville, CA       61     2371  
892             Pasadena, CA       39     2299  
929             Red Bank, NJ      -16     2149  
963   Palm Beach Gardens, FL       84     2022  
985               Dallas, TX       37     1929  
994               Denver, CO       66     1909  
Group: Health Care                          Company  Employees  \
Rank                                          
5                       McKesson      70400   
6             UnitedHealth Group     200000   
12             AmerisourceBergen      17000   
21               Cardinal Health      34500   
22       Express Scripts Holding      25900   
33                        Anthem      53000   
39             Johnson & Johnson     127100   
46                         Aetna      50100   
52                        Humana      50100   
55                        Pfizer      97900   
63                  HCA Holdings     203500   
72                         Merck      68000   
79                         Cigna      39300   
86               Gilead Sciences       8000   
123                       AbbVie      28000   
124                      Centene      18200   
125     Community Health Systems     123000   
130                        Amgen      17900   
138          Abbott Laboratories      74000   
140             Tenet Healthcare     119148   
141                    Eli Lilly      41275   
168         Bristol-Myers Squibb      25000   
172                   Health Net       8584   
200   DaVita HealthCare Partners      60400   
201            Molina Healthcare      21000   
202        WellCare Health Plans       6900   
263                       Biogen       7350   
268                 Henry Schein      19000   
278             Becton Dickinson      49517   
286         Baxter International      49400   
...                          ...        ...   
515      Brookdale Senior Living      67500   
527                       Zoetis       9000   
537              Magellan Health       6900   
553                       Cerner      22200   
559                    Patterson       7000   
583    Regeneron Pharmaceuticals       4300   
618      Select Medical Holdings      34700   
629         Team Health Holdings      18800   
661                    C.R. Bard      15000   
684                         NBTY      13100   
693                  HealthSouth      27929   
697             Iasis Healthcare      11950   
708       Varian Medical Systems       7300   
746          IMS Health Holdings      15000   
749          Triple-S Management       3405   
766                       AmSurg      10700   
775                       Mednax       8645   
790                      Hologic       5290   
799              Dentsply Sirona      11400   
815      Alexion Pharmaceuticals       2924   
818                        Alere       9800   
845         Edwards Lifesciences       9800   
868           Intuitive Surgical       3211   
881        Parexel International      18660   
883              inVentiv Health      14000   
935                          VCA      12700   
960                   PharMerica       5200   
965         Bio-Rad Laboratories       7770   
977            Hill-Rom Holdings      10000   
978           Providence Service       9072   

                                      Industry               Location  \
Rank                                                                    
5                     Wholesalers: Health Care      San Francisco, CA   
6      Health Care: Insurance and Managed Care         Minnetonka, MN   
12                    Wholesalers: Health Care       Chesterbrook, PA   
21                    Wholesalers: Health Care             Dublin, OH   
22    Health Care: Pharmacy and Other Services          St. Louis, MO   
33     Health Care: Insurance and Managed Care       Indianapolis, IN   
39                             Pharmaceuticals      New Brunswick, NJ   
46     Health Care: Insurance and Managed Care           Hartford, CT   
52     Health Care: Insurance and Managed Care         Louisville, KY   
55                             Pharmaceuticals           New York, NY   
63             Health Care: Medical Facilities          Nashville, TN   
72                             Pharmaceuticals         Kenilworth, NJ   
79     Health Care: Insurance and Managed Care         Bloomfield, CT   
86                             Pharmaceuticals        Foster City, CA   
123                            Pharmaceuticals      North Chicago, IL   
124    Health Care: Insurance and Managed Care          St. Louis, MO   
125            Health Care: Medical Facilities           Franklin, TN   
130                            Pharmaceuticals      Thousand Oaks, CA   
138             Medical Products and Equipment        Abbott Park, IL   
140            Health Care: Medical Facilities             Dallas, TX   
141                            Pharmaceuticals       Indianapolis, IN   
168                            Pharmaceuticals           New York, NY   
172    Health Care: Insurance and Managed Care     Woodland Hills, CA   
200            Health Care: Medical Facilities             Denver, CO   
201    Health Care: Insurance and Managed Care         Long Beach, CA   
202    Health Care: Insurance and Managed Care              Tampa, FL   
263                            Pharmaceuticals          Cambridge, MA   
268                   Wholesalers: Health Care           Melville, NY   
278             Medical Products and Equipment     Franklin Lakes, NJ   
286             Medical Products and Equipment          Deerfield, IL   
...                                        ...                    ...   
515            Health Care: Medical Facilities          Brentwood, TN   
527                            Pharmaceuticals       Florham Park, NJ   
537    Health Care: Insurance and Managed Care         Scottsdale, AZ   
553   Health Care: Pharmacy and Other Services  North Kansas City, MO   
559                   Wholesalers: Health Care           St. Paul, MN   
583                            Pharmaceuticals          Tarrytown, NY   
618            Health Care: Medical Facilities      Mechanicsburg, PA   
629   Health Care: Pharmacy and Other Services          Knoxville, TN   
661             Medical Products and Equipment        Murray Hill, NJ   
684                            Pharmaceuticals         Ronkonkoma, NY   
693            Health Care: Medical Facilities         Birmingham, AL   
697            Health Care: Medical Facilities           Franklin, TN   
708             Medical Products and Equipment          Palo Alto, CA   
746   Health Care: Pharmacy and Other Services            Danbury, CT   
749    Health Care: Insurance and Managed Care           San Juan, PR   
766            Health Care: Medical Facilities          Nashville, TN   
775   Health Care: Pharmacy and Other Services            Sunrise, FL   
790             Medical Products and Equipment        Marlborough, MA   
799             Medical Products and Equipment               York, PA   
815                            Pharmaceuticals          New Haven, CT   
818             Medical Products and Equipment            Waltham, MA   
845             Medical Products and Equipment             Irvine, CA   
868             Medical Products and Equipment          Sunnyvale, CA   
881   Health Care: Pharmacy and Other Services            Waltham, MA   
883   Health Care: Pharmacy and Other Services         Burlington, MA   
935            Health Care: Medical Facilities        Los Angeles, CA   
960   Health Care: Pharmacy and Other Services         Louisville, KY   
965             Medical Products and Equipment           Hercules, CA   
977             Medical Products and Equipment            Chicago, IL   
978   Health Care: Pharmacy and Other Services             Tucson, AZ   

      Profits  Revenue  
Rank                    
5        1476   181241  
6        5813   157107  
12       -135   135962  
21       1215   102531  
22       2476   101752  
33       2560    79157  
39      15409    70074  
46       2390    60337  
52       1276    54289  
55       6960    48851  
63       2129    43591  
72       4442    39498  
79       2094    37876  
86      18108    32639  
123      5144    22859  
124       355    22795  
125       158    22678  
130      6939    21662  
138      4423    20661  
140      -140    20111  
141      2408    19959  
168      1565    16560  
172       186    16244  
200       270    14210  
201       143    14178  
202       119    13890  
263      3547    10764  
268       479    10630  
278       695    10282  
286       968     9968  
...       ...      ...  
515      -458     4961  
527       339     4765  
537        31     4597  
553       539     4425  
559       223     4375  
583       636     4104  
618       131     3743  
629        83     3597  
661       135     3416  
684        74     3226  
693       183     3163  
697        -8     3158  
708       412     3099  
746       417     2921  
749        52     2903  
766       163     2833  
775       336     2780  
790       132     2705  
799       251     2674  
815       144     2604  
818       346     2601  
845       495     2494  
868       589     2384  
881       148     2330  
883      -152     2321  
935       211     2134  
960        35     2029  
965       113     2019  
977        48     1988  
978        84     1987  

[75 rows x 6 columns]
Group: Materials                          Company  Employees                   Industry  \
Rank                                                                     
126                        Alcoa      60000                     Metals   
127          International Paper      56000      Packaging, Containers   
170                        Nucor      23700                     Metals   
244          United States Steel      33200                     Metals   
251                     WestRock      41400      Packaging, Containers   
303    Reliance Steel & Aluminum      13400                     Metals   
321               Crown Holdings      24000      Packaging, Containers   
341                         Ball      15200      Packaging, Containers   
356               Steel Dynamics       7500                     Metals   
373                 Weyerhaeuser      12600  Forest and Paper Products   
375                   Sealed Air      23000      Packaging, Containers   
383             AK Steel Holding       8500                     Metals   
417            Commercial Metals       9126                     Metals   
418               Owens-Illinois      27000      Packaging, Containers   
426       A-Mark Precious Metals         52              Miscellaneous   
435               Avery Dennison      25000      Packaging, Containers   
446   Packaging Corp. of America      13000      Packaging, Containers   
480                Owens Corning      15000  Building Materials, Glass   
489                       Domtar       9850  Forest and Paper Products   
514              Sonoco Products      21000      Packaging, Containers   
518         Berry Plastics Group      16000      Packaging, Containers   
577    Graphic Packaging Holding      12000      Packaging, Containers   
586                        Bemis      17696      Packaging, Containers   
616                          USG       8900  Building Materials, Glass   
617              Silgan Holdings       9600      Packaging, Containers   
620       Allegheny Technologies       9200                     Metals   
625     Resolute Forest Products       8000  Forest and Paper Products   
628                        Greif      13150      Packaging, Containers   
637         Builders FirstSource      14000  Building Materials, Glass   
639                     Carlisle      12000  Building Materials, Glass   
641    Martin Marietta Materials       7299  Building Materials, Glass   
660             Vulcan Materials       7187  Building Materials, Glass   
667       Worthington Industries      10500                     Metals   
687                       Aleris       5200                     Metals   
691              Ryerson Holding       3600                     Metals   
751    Universal Forest Products       7000  Forest and Paper Products   
774   KapStone Paper & Packaging       6400      Packaging, Containers   
793                        Verso       1630  Forest and Paper Products   
857   Armstrong World Industries       7600  Building Materials, Glass   
885                   AptarGroup      13000      Packaging, Containers   
911         Carpenter Technology       4900                     Metals   
982             Century Aluminum       1778                     Metals   
986   Schnitzer Steel Industries       2955                     Metals   

              Location  Profits  Revenue  
Rank                                      
126       New York, NY     -322    22534  
127        Memphis, TN      938    22365  
170      Charlotte, NC      358    16439  
244     Pittsburgh, PA    -1642    11574  
251       Richmond, VA      507    11381  
303    Los Angeles, CA      312     9351  
321   Philadelphia, PA      393     8762  
341     Broomfield, CO      281     7997  
356     Fort Wayne, IN     -130     7594  
373    Federal Way, WA      506     7082  
375      Charlotte, NC      335     7032  
383   West Chester, OH     -509     6693  
417         Irving, TX      142     6162  
418     Perrysburg, OH      -74     6156  
426   Santa Monica, CA        7     6070  
435       Glendale, CA      274     5967  
446    Lake Forest, IL      437     5742  
480         Toledo, OH      330     5350  
489      Fort Mill, SC      142     5264  
514     Hartsville, SC      250     4964  
518     Evansville, IN       86     4881  
577        Atlanta, GA      230     4160  
586         Neenah, WI      239     4071  
616        Chicago, IL      991     3776  
617       Stamford, CT      172     3764  
620     Pittsburgh, PA     -378     3720  
625        Catawba, SC     -257     3645  
628       Delaware, OH       72     3617  
637         Dallas, TX      -23     3564  
639      Charlotte, NC      320     3543  
641        Raleigh, NC      289     3540  
660     Birmingham, AL      221     3422  
667       Columbus, OH       77     3384  
687      Cleveland, OH       49     3206  
691        Chicago, IL       -1     3167  
751   Grand Rapids, MI       81     2887  
774     Northbrook, IL      106     2789  
793        Memphis, TN     -477     2692  
857      Lancaster, PA       94     2420  
885   Crystal Lake, IL      199     2317  
911     Wyomissing, PA       59     2227  
982        Chicago, IL      -59     1950  
986       Portland, OR     -197     1924  
Group: Aerospace & Defense                             Company  Employees               Industry  \
Rank                                                                    
24                           Boeing     161400  Aerospace and Defense   
45              United Technologies     197200  Aerospace and Defense   
60                  Lockheed Martin     126000  Aerospace and Defense   
88                 General Dynamics      99900  Aerospace and Defense   
118                Northrop Grumman      65000  Aerospace and Defense   
120                        Raytheon      61000  Aerospace and Defense   
209                         Textron      35000  Aerospace and Defense   
245              L-3 Communications      38000  Aerospace and Defense   
282             Precision Castparts      30106  Aerospace and Defense   
378   Huntington Ingalls Industries      35995  Aerospace and Defense   
389     Spirit AeroSystems Holdings      15200  Aerospace and Defense   
490                Rockwell Collins      19500  Aerospace and Defense   
560                     Orbital ATK      12300  Aerospace and Defense   
605                   Triumph Group      15153  Aerospace and Defense   
785                   B/E Aerospace      10057  Aerospace and Defense   
788                 TransDigm Group       8200  Aerospace and Defense   
836                            Moog      10691  Aerospace and Defense   
903                  Curtiss-Wright       8400  Aerospace and Defense   
958                        Woodward       6955  Aerospace and Defense   
987           Delta Tucker Holdings      12000  Aerospace and Defense   

              Location  Profits  Revenue  
Rank                                      
24         Chicago, IL     5176    96114  
45      Farmington, CT     7608    61047  
60        Bethesda, MD     3605    46132  
88    Falls Church, VA     2965    31469  
118   Falls Church, VA     1990    23526  
120        Waltham, MA     2074    23247  
209     Providence, RI      697    13423  
245       New York, NY     -240    11554  
282       Portland, OR     1530    10056  
378   Newport News, VA      404     7020  
389        Wichita, KS      789     6644  
490   Cedar Rapids, IA      686     5262  
560         Dulles, VA      159     4369  
605         Berwyn, PA      239     3889  
785     Wellington, FL      286     2730  
788      Cleveland, OH      447     2707  
836           Elma, NY      132     2526  
903      Charlotte, NC      146     2264  
958   Fort Collins, CO      182     2038  
987         McLean, VA     -133     1923  
Group: Apparel                    Company  Employees Industry             Location  Profits  \
Rank                                                                           
91                    Nike      62600  Apparel        Beaverton, OR     3273   
231                     VF      64000  Apparel       Greensboro, NC     1232   
340                    PVH      26200  Apparel         New York, NY      572   
354           Ralph Lauren      20000  Apparel         New York, NY      702   
448            Hanesbrands      65300  Apparel    Winston-Salem, NC      429   
547           Levi Strauss      12500  Apparel    San Francisco, CA      209   
575                  Coach      12950  Apparel         New York, NY      402   
597           Under Armour       9600  Apparel        Baltimore, MD      233   
683           Fossil Group      15100  Apparel       Richardson, TX      221   
695        Skechers U.S.A.       6400  Apparel  Manhattan Beach, CA      232   
726               Carter’s      16800  Apparel          Atlanta, GA      238   
794   Wolverine World Wide       6550  Apparel         Rockford, MI      123   
877    G-III Apparel Group       8919  Apparel         New York, NY      114   
882    Columbia Sportswear       5978  Apparel         Portland, OR      174   
917                  Guess      13500  Apparel      Los Angeles, CA       82   

      Revenue  
Rank           
91      30601  
231     12377  
340      8020  
354      7620  
448      5732  
547      4495  
575      4192  
597      3963  
683      3229  
695      3159  
726      3014  
794      2692  
877      2344  
882      2326  
917      2204  
Group: Motor Vehicles & Parts                             Company  Employees                  Industry  \
Rank                                                                       
8                    General Motors     215000  Motor Vehicles and Parts   
9                        Ford Motor     199000  Motor Vehicles and Parts   
70                 Johnson Controls     139000  Motor Vehicles and Parts   
147                          Paccar      23000  Motor Vehicles and Parts   
154                            Lear     136200  Motor Vehicles and Parts   
169          Goodyear Tire & Rubber      66000  Motor Vehicles and Parts   
281          Navistar International      13800  Motor Vehicles and Parts   
310                         Autoliv      59350  Motor Vehicles and Parts   
334                         Tenneco      30000  Motor Vehicles and Parts   
339                      BorgWarner      30000  Motor Vehicles and Parts   
424                         Oshkosh      13300  Motor Vehicles and Parts   
428                    Dana Holding      23100  Motor Vehicles and Parts   
470                         Visteon      11000  Motor Vehicles and Parts   
588                    Tesla Motors      13058  Motor Vehicles and Parts   
591                 Thor Industries      10450  Motor Vehicles and Parts   
604   American Axle & Manufacturing      13054  Motor Vehicles and Parts   
647                         Meritor       8400  Motor Vehicles and Parts   
670        Cooper-Standard Holdings      29000  Motor Vehicles and Parts   
718     Metaldyne Performance Group      12000  Motor Vehicles and Parts   
739            Cooper Tire & Rubber       9119  Motor Vehicles and Parts   
811                  WABCO Holdings      12429  Motor Vehicles and Parts   
957             Tower International       8300  Motor Vehicles and Parts   
961                 Wabash National       5300  Motor Vehicles and Parts   
979   Allison Transmission Holdings       2700  Motor Vehicles and Parts   

                    Location  Profits  Revenue  
Rank                                            
8                Detroit, MI     9687   152356  
9               Dearborn, MI     7373   149558  
70             Milwaukee, WI     1563    40204  
147             Bellevue, WA     1604    19115  
154           Southfield, MI      746    18211  
169                Akron, OH      307    16443  
281                Lisle, IL     -184    10140  
310         Auburn Hills, MI      457     9170  
334          Lake Forest, IL      247     8209  
339         Auburn Hills, MI      610     8023  
424              Oshkosh, WI      230     6098  
428               Maumee, OH      159     6060  
470   Van Buren Township, MI     2284     5444  
588            Palo Alto, CA     -889     4046  
591              Elkhart, IN      199     4007  
604              Detroit, MI      236     3903  
647                 Troy, MI       64     3506  
670                 Novi, MI      112     3343  
718           Southfield, MI      125     3047  
739              Findlay, OH      213     2973  
811      Rochester Hills, MI      275     2628  
957              Livonia, MI      194     2042  
961            Lafayette, IN      104     2028  
979         Indianaoplis, IN      182     1986  
Group: Industrials                                   Company  Employees  \
Rank                                                   
11                       General Electric     333000   
59                            Caterpillar     112200   
75                Honeywell International     129000   
93                                     3M      89446   
97                                  Deere      57180   
128                      Emerson Electric     110800   
134                             Whirlpool      97000   
148                               Cummins      55200   
211                   Illinois Tool Works      48000   
224                       Parker-Hannifin      54750   
360                                  AGCO      19588   
377                                 Dover      26000   
396                                 Terex      20400   
412                   Rockwell Automation      22500   
419       Harman International Industries      24197   
539                             Flowserve      19000   
544                         General Cable      12000   
596                                Colfax      17087   
622                                 Xylem      12700   
623                    Zebra Technologies       7000   
630                               Snap-on      11500   
645                          Regal Beloit      26200   
655                  Lennox International      10000   
658                             Manitowoc      11430   
666                               Hubbell      16200   
674   Westinghouse Air Brake Technologies      13000   
690                            Joy Global      13400   
757                                Timken      14709   
782                                 Crane      11200   
789                         Acuity Brands       7800   
806                            Kennametal      12700   
813                    Valmont Industries      10697   
823        Hyster-Yale Materials Handling       5400   
831                            A.O. Smith      13386   
832             Lincoln Electric Holdings      10000   
835                                Nortek      11400   
841                               EnerSys       9500   
847                                   ITT       9700   
866                                  Toro       6874   
867                              SPX FLOW       8000   
873                             Donaldson      12500   
887                                Belden       8200   
942                    Mueller Industries       4104   
947                               Rexnord       8000   
964                                  IDEX       6801   
1000                    Briggs & Stratton       5480   

                             Industry                Location  Profits  \
Rank                                                                     
11               Industrial Machinery           Fairfield, CT    -6126   
59    Construction and Farm Machinery              Peoria, IL     2102   
75     Electronics, Electrical Equip.       Morris Plains, NJ     4768   
93                      Miscellaneous            St. Paul, MN     4833   
97    Construction and Farm Machinery              Moline, IL     1940   
128    Electronics, Electrical Equip.           St. Louis, MO     2710   
134    Electronics, Electrical Equip.       Benton Harbor, MI      783   
148   Construction and Farm Machinery            Columbus, IN     1399   
211              Industrial Machinery            Glenview, IL     1899   
224              Industrial Machinery           Cleveland, OH     1012   
360   Construction and Farm Machinery              Duluth, GA      266   
377              Industrial Machinery       Downers Grove, IL      870   
396   Construction and Farm Machinery            Westport, CT      146   
412    Electronics, Electrical Equip.           Milwaukee, WI      828   
419    Electronics, Electrical Equip.            Stamford, CT      343   
539              Industrial Machinery              Irving, TX      268   
544    Electronics, Electrical Equip.    Highland Heights, KY     -122   
596              Industrial Machinery  Annapolis Junction, MD      168   
622              Industrial Machinery           Rye Brook, NY      340   
623    Electronics, Electrical Equip.        Lincolnshire, IL     -137   
630              Industrial Machinery             Kenosha, WI      479   
645    Electronics, Electrical Equip.              Beloit, WI      143   
655              Industrial Machinery          Richardson, TX      187   
658   Construction and Farm Machinery           Manitowoc, WI       64   
666    Electronics, Electrical Equip.             Shelton, CT      277   
674              Industrial Machinery          Wilmerding, PA      399   
690   Construction and Farm Machinery           Milwaukee, WI    -1178   
757              Industrial Machinery        North Canton, OH      -71   
782              Industrial Machinery            Stamford, CT      229   
789    Electronics, Electrical Equip.             Atlanta, GA      222   
806              Industrial Machinery          Pittsburgh, PA     -374   
813   Construction and Farm Machinery               Omaha, NE       40   
823              Industrial Machinery           Cleveland, OH       75   
831    Electronics, Electrical Equip.           Milwaukee, WI      283   
832              Industrial Machinery           Cleveland, OH      128   
835              Industrial Machinery          Providence, RI      -27   
841    Electronics, Electrical Equip.             Reading, PA      181   
847              Industrial Machinery        White Plains, NY      352   
866   Construction and Farm Machinery         Bloomington, MN      202   
867              Industrial Machinery           Charlotte, NC       88   
873              Industrial Machinery         Minneapolis, MN      208   
887    Electronics, Electrical Equip.           St. Louis, MO       66   
942              Industrial Machinery             Memphis, TN       88   
947              Industrial Machinery           Milwaukee, WI       84   
964              Industrial Machinery         Lake Forest, IL      283   
1000             Industrial Machinery           Wauwatosa, WI       46   

      Revenue  
Rank           
11     140389  
59      47011  
75      38581  
93      30274  
97      28863  
128     22304  
134     20891  
148     19110  
211     13405  
224     12712  
360      7467  
377      7029  
396      6543  
412      6308  
419      6155  
539      4561  
544      4515  
596      3967  
622      3653  
623      3652  
630      3593  
645      3510  
655      3467  
658      3436  
666      3390  
674      3308  
690      3172  
757      2872  
782      2741  
789      2707  
806      2647  
813      2619  
823      2578  
831      2537  
832      2536  
835      2526  
841      2506  
847      2486  
866      2391  
867      2389  
873      2371  
887      2309  
942      2100  
947      2084  
964      2021  
1000     1895  
Group: Technology                              Company  Employees  \
Rank                                              
3                              Apple     110000   
18                        Amazon.com     230800   
20                                HP     287000   
25                         Microsoft     118000   
31                               IBM     411798   
36                          Alphabet      61814   
51                             Intel     107300   
54                     Cisco Systems      71833   
77                            Oracle     132000   
110                         Qualcomm      33000   
113                              EMC      72000   
133                          Danaher      81000   
150                            Xerox     143600   
157                         Facebook      12691   
158                    Jabil Circuit     161000   
164         Thermo Fisher Scientific      52400   
173                Micron Technology      31800   
194                  Western Digital      76449   
219                Texas Instruments      29977   
220                              CDW       8465   
230   Cognizant Technology Solutions     221700   
233                Computer Sciences      70000   
284              Liberty Interactive      22080   
295                Applied Materials      15050   
300                             eBay      11600   
308                  Priceline Group      15500   
313                          Corning      35700   
331                         Broadcom       9950   
385                          Expedia      18730   
386                   salesforce.com      19742   
...                              ...        ...   
778                          Diebold      16000   
805                           Plexus      14000   
830            Benchmark Electronics      10500   
834                         Teradata      11300   
842                         Autodesk       9500   
854                            Ciena       5345   
864     Mettler-Toledo International      13000   
871                           Xilinx       3451   
888        Maxim Integrated Products       8250   
891           Vishay Intertechnology      22400   
893            Teledyne Technologies       9200   
896               Trimble Navigation       8451   
904   Brocade Communications Systems       4640   
905                      PerkinElmer       8000   
906                          Wayfair       3809   
909                         Synopsys      10284   
912                         Illumina       4600   
914                          Twitter       3898   
919              Akamai Technologies       6084   
927                          Gartner       7834   
931             Microchip Technology       9449   
943                          Maximus      17000   
944                 TTM Technologies      29570   
946                Engility Holdings       9800   
956                           Waters       6594   
970                Rackspace Hosting       6189   
971                 VeriFone Systems       5400   
975             Super Micro Computer       2285   
984            Nuance Communications      13500   
990                      F5 Networks       4178   

                                            Industry            Location  \
Rank                                                                       
3                        Computers, Office Equipment       Cupertino, CA   
18                   Internet Services and Retailing         Seattle, WA   
20                       Computers, Office Equipment       Palo Alto, CA   
25                                 Computer Software         Redmond, WA   
31                   Information Technology Services          Armonk, NY   
36                   Internet Services and Retailing   Mountain View, CA   
51    Semiconductors and Other Electronic Components     Santa Clara, CA   
54        Network and Other Communications Equipment        San Jose, CA   
77                                 Computer Software    Redwood City, CA   
110       Network and Other Communications Equipment       San Diego, CA   
113                             Computer Peripherals       Hopkinton, MA   
133    Scientific,Photographic and Control Equipment      Washington, DC   
150                  Information Technology Services         Norwalk, CT   
157                  Internet Services and Retailing      Menlo Park, CA   
158   Semiconductors and Other Electronic Components  St. Petersburg, FL   
164    Scientific,Photographic and Control Equipment         Waltham, MA   
173   Semiconductors and Other Electronic Components           Boise, ID   
194                             Computer Peripherals          Irvine, CA   
219   Semiconductors and Other Electronic Components          Dallas, TX   
220                  Information Technology Services    Lincolnshire, IL   
230                  Information Technology Services         Teaneck, NJ   
233                  Information Technology Services    Falls Church, VA   
284                  Internet Services and Retailing       Englewood, CO   
295   Semiconductors and Other Electronic Components     Santa Clara, CA   
300                  Internet Services and Retailing        San Jose, CA   
308                  Internet Services and Retailing         Norwalk, CT   
313       Network and Other Communications Equipment         Corning, NY   
331   Semiconductors and Other Electronic Components          Irvine, CA   
385                  Internet Services and Retailing        Bellevue, WA   
386                                Computer Software   San Francisco, CA   
...                                              ...                 ...   
778                      Computers, Office Equipment    North Canton, OH   
805   Semiconductors and Other Electronic Components          Neenah, WI   
830   Semiconductors and Other Electronic Components        Angleton, TX   
834                                Computer Software          Dayton, OH   
842                                Computer Software      San Rafael, CA   
854       Network and Other Communications Equipment         Hanover, MD   
864    Scientific,Photographic and Control Equipment        Columbus, OH   
871   Semiconductors and Other Electronic Components        San Jose, CA   
888   Semiconductors and Other Electronic Components        San Jose, CA   
891   Semiconductors and Other Electronic Components         Malvern, PA   
893    Scientific,Photographic and Control Equipment   Thousand Oaks, CA   
896    Scientific,Photographic and Control Equipment       Sunnyvale, CA   
904       Network and Other Communications Equipment        San Jose, CA   
905    Scientific,Photographic and Control Equipment         Waltham, MA   
906                  Internet Services and Retailing          Boston, MA   
909                                Computer Software   Mountain View, CA   
912    Scientific,Photographic and Control Equipment       San Diego, CA   
914                  Internet Services and Retailing   San Francisco, CA   
919                                Computer Software       Cambridge, MA   
927                  Information Technology Services        Stamford, CT   
931   Semiconductors and Other Electronic Components        Chandler, AZ   
943                  Information Technology Services          Reston, VA   
944   Semiconductors and Other Electronic Components      Costa Mesa, CA   
946                  Information Technology Services       Chantilly, VA   
956    Scientific,Photographic and Control Equipment         Milford, MA   
970                  Internet Services and Retailing     San Antonio, TX   
971                      Computers, Office Equipment        San Jose, CA   
975                      Computers, Office Equipment        San Jose, CA   
984                                Computer Software      Burlington, MA   
990       Network and Other Communications Equipment         Seattle, WA   

      Profits  Revenue  
Rank                    
3       53394   233715  
18        596   107006  
20       4554   103355  
25      12193    93580  
31      13190    82461  
36      16348    74989  
51      11420    55355  
54       8981    49161  
77       9938    38226  
110      5271    25281  
113      1990    24704  
133      3357    20909  
150       474    18664  
157      3688    17928  
158       284    17914  
164      1975    16965  
173      2899    16192  
194      1465    14572  
219      2986    13000  
220       403    12989  
230      1624    12416  
233        -8    12183  
284       869     9989  
295      1377     9659  
300      1725     9496  
308      2551     9224  
313      1339     9111  
331       978     8394  
385       765     6672  
386       -47     6667  
...       ...      ...  
778        74     2768  
805        94     2654  
830        95     2541  
834      -214     2530  
842      -331     2504  
854        12     2446  
864       353     2395  
871       648     2377  
888       206     2307  
891      -109     2301  
893       196     2298  
896       121     2290  
904       340     2264  
905       212     2263  
906       -77     2250  
909       226     2242  
912       462     2220  
914      -521     2218  
919       321     2197  
927       176     2163  
931       369     2147  
943       158     2100  
944       -26     2096  
946      -235     2086  
956       469     2042  
970       126     2001  
971        79     2001  
975       102     1991  
984      -115     1931  
990       365     1920  

[102 rows x 6 columns]
Group: Telecommunications                          Company  Employees            Industry  \
Rank                                                              
10                          AT&T     281450  Telecommunications   
13                       Verizon     177700  Telecommunications   
37                       Comcast     153000  Telecommunications   
116            Time Warner Cable      56430  Telecommunications   
159                  CenturyLink      43000  Telecommunications   
187                 DISH Network      18000  Telecommunications   
292       Charter Communications      23800  Telecommunications   
333       Level 3 Communications      12500  Telecommunications   
399          Cablevision Systems      13549  Telecommunications   
443          Windstream Holdings      12326  Telecommunications   
461      Frontier Communications      19200  Telecommunications   
496     Telephone & Data Systems      10400  Telecommunications   
526               American Tower       3371  Telecommunications   
619   Crown Castle International       2700  Telecommunications   
786                      Equinix       5042  Telecommunications   

              Location  Profits  Revenue  
Rank                                      
10          Dallas, TX    13345   146801  
13        New York, NY    17879   131620  
37    Philadelphia, PA     8163    74510  
116       New York, NY     1844    23697  
159         Monroe, LA      878    17900  
187      Englewood, CO      747    15069  
292       Stamford, CT     -271     9754  
333     Broomfield, CO     3433     8229  
399       Bethpage, NY      175     6510  
443    Little Rock, AR       27     5765  
461        Norwalk, CT     -196     5576  
496        Chicago, IL      219     5176  
526         Boston, MA      685     4772  
619        Houston, TX     1521     3729  
786   Redwood City, CA      188     2726  
Group: Financials                                   Company  Employees  \
Rank                                                   
4                      Berkshire Hathaway     331000   
16                             Fannie Mae       7300   
23                      J.P. Morgan Chase     234598   
26                  Bank of America Corp.     213280   
27                            Wells Fargo     264700   
29                              Citigroup     231000   
35              State Farm Insurance Cos.      70425   
40                                MetLife      69000   
43                            Freddie Mac       5439   
49                                    AIG      66400   
50                   Prudential Financial      49384   
61                New York Life Insurance      11463   
69                             Nationwide      34032   
73         Liberty Mutual Insurance Group      50000   
74                    Goldman Sachs Group      36800   
76    Massachusetts Mutual Life Insurance      11593   
78                         Morgan Stanley      56218   
81                               Allstate      41350   
82                                   TIAA      12735   
83                           INTL FCStone       1231   
85                       American Express      54800   
100                   Northwestern Mutual       5530   
105                        Travelers Cos.      30900   
112                 Capital One Financial      45400   
114                                  USAA      28681   
131                          U.S. Bancorp      65433   
135                                 Aflac       9915   
137                           Progressive      28580   
152     Hartford Financial Services Group      17400   
171          PNC Financial Services Group      50831   
...                                   ...        ...   
750              StanCorp Financial Group       2767   
755                Sentry Insurance Group       4169   
765                              Comerica       8818   
768                            Legg Mason       2982   
781                    Equity Residential       3500   
828                                   HCP        187   
833                  Vornado Realty Trust       4089   
838             National General Holdings       4630   
839                          Aretec Group       2116   
844      Mutual of America Life Insurance       1093   
846                     Boston Properties        765   
848             Affiliated Managers Group       3200   
852                Medical Mutual of Ohio       2186   
861             General Growth Properties       1700   
872                      Stifel Financial       7100   
878                                Kemper       5600   
880          Nationstar Mortgage Holdings       6740   
897            Penn Mutual Life Insurance       1022   
910                Amica Mutual Insurance       3512   
916                        Zions Bancorp.      10200   
920                              Prologis       1555   
923                      OneMain Holdings      11400   
925                   Knights of Columbus        929   
926                     Symetra Financial       1400   
936             Selective Insurance Group       2200   
938                               Popular       7810   
959          Stewart Information Services       6900   
976                   First Republic Bank       3130   
988          Hospitality Properties Trust        400   
996            New York Community Bancorp       3448   

                                       Industry              Location  \
Rank                                                                    
4      Insurance: Property and Casualty (Stock)             Omaha, NE   
16                       Diversified Financials        Washington, DC   
23                             Commercial Banks          New York, NY   
26                             Commercial Banks         Charlotte, NC   
27                             Commercial Banks     San Francisco, CA   
29                             Commercial Banks          New York, NY   
35    Insurance: Property and Casualty (Mutual)       Bloomington, IL   
40              Insurance: Life, Health (stock)          New York, NY   
43                       Diversified Financials            McLean, VA   
49     Insurance: Property and Casualty (Stock)          New York, NY   
50              Insurance: Life, Health (stock)            Newark, NJ   
61             Insurance: Life, Health (Mutual)          New York, NY   
69    Insurance: Property and Casualty (Mutual)          Columbus, OH   
73     Insurance: Property and Casualty (Stock)            Boston, MA   
74                             Commercial Banks          New York, NY   
76             Insurance: Life, Health (Mutual)       Springfield, MA   
78                             Commercial Banks          New York, NY   
81     Insurance: Property and Casualty (Stock)        Northbrook, IL   
82             Insurance: Life, Health (Mutual)          New York, NY   
83                       Diversified Financials          New York, NY   
85                       Diversified Financials          New York, NY   
100            Insurance: Life, Health (Mutual)         Milwaukee, WI   
105    Insurance: Property and Casualty (Stock)          New York, NY   
112                            Commercial Banks            McLean, VA   
114    Insurance: Property and Casualty (Stock)       San Antonio, TX   
131                            Commercial Banks       Minneapolis, MN   
135             Insurance: Life, Health (stock)          Columbus, GA   
137    Insurance: Property and Casualty (Stock)  Mayfield Village, OH   
152    Insurance: Property and Casualty (Stock)          Hartford, CT   
171                            Commercial Banks        Pittsburgh, PA   
...                                         ...                   ...   
750             Insurance: Life, Health (stock)          Portland, OR   
755   Insurance: Property and Casualty (Mutual)     Stevens Point, WI   
765                            Commercial Banks            Dallas, TX   
768                                  Securities         Baltimore, MD   
781                                 Real estate           Chicago, IL   
828                                 Real estate            Irvine, CA   
833                                 Real estate          New York, NY   
838    Insurance: Property and Casualty (Stock)          New York, NY   
839                                  Securities          New York, NY   
844            Insurance: Life, Health (Mutual)          New York, NY   
846                                 Real estate            Boston, MA   
848                                  Securities   West Palm Beach, FL   
852            Insurance: Life, Health (Mutual)         Cleveland, OH   
861                                 Real estate           Chicago, IL   
872                                  Securities         St. Louis, MO   
878    Insurance: Property and Casualty (Stock)           Chicago, IL   
880                      Diversified Financials           Coppell, TX   
897             Insurance: Life, Health (stock)           Horsham, PA   
910   Insurance: Property and Casualty (Mutual)           Lincoln, RI   
916                            Commercial Banks    Salt Lake City, UT   
920                                 Real estate     San Francisco, CA   
923                      Diversified Financials        Evansville, IN   
925            Insurance: Life, Health (Mutual)         New Haven, CT   
926             Insurance: Life, Health (stock)          Bellevue, WA   
936    Insurance: Property and Casualty (Stock)       Branchville, NJ   
938                            Commercial Banks          Hato Rey, PR   
959    Insurance: Property and Casualty (Stock)           Houston, TX   
976                            Commercial Banks     San Francisco, CA   
988                                 Real estate            Newton, MA   
996                            Commercial Banks          Westbury, NY   

      Profits  Revenue  
Rank                    
4       24083   210821  
16      10954   110359  
23      24442   101006  
26      15888    93056  
27      22894    90033  
29      17242    88275  
35       6229    75697  
40       5310    69951  
43       6376    63491  
49       2196    58327  
50       5642    57119  
61        257    45891  
69        581    40222  
73        514    39450  
74       6083    39208  
76       1425    38243  
78       6127    37897  
81       2171    35653  
82       1214    35181  
83         56    34693  
85       5163    34441  
100       815    28111  
105      3439    26800  
112      4050    25098  
114      2272    24361  
131      5879    21494  
135      2533    20872  
137      1268    20854  
152      1682    18377  
171      4106    16270  
...       ...      ...  
750       215     2902  
755       284     2883  
765       521     2834  
768       237     2819  
781       870     2746  
828      -559     2544  
833       760     2530  
838       142     2511  
839      -509     2509  
844        65     2495  
846       583     2491  
848       516     2485  
852       120     2462  
861      1375     2404  
872        92     2377  
878        86     2341  
880        39     2339  
897       209     2290  
910        63     2231  
916       310     2211  
920       869     2197  
923      -242     2192  
925        68     2180  
926       147     2179  
936       166     2132  
938       895     2123  
959        -6     2034  
976       522     1989  
988       166     1922  
996       -47     1902  

[139 rows x 6 columns]
Group: Hotels, Resturants & Leisure                                Company  Employees                  Industry  \
Rank                                                                          
109                         McDonald’s     420000             Food Services   
146                          Starbucks     238000             Food Services   
195             Marriott International     127500  Hotels, Casinos, Resorts   
218                         Yum Brands     505000             Food Services   
241                    Las Vegas Sands      46500  Hotels, Casinos, Resorts   
254          Hilton Worldwide Holdings     164000  Hotels, Casinos, Resorts   
309          MGM Resorts International      57950  Hotels, Casinos, Resorts   
371                 Darden Restaurants     148892             Food Services   
444          Starwood Hotels & Resorts     188000  Hotels, Casinos, Resorts   
466                  Wyndham Worldwide      37700  Hotels, Casinos, Resorts   
534              Caesars Entertainment      33000  Hotels, Casinos, Resorts   
546             Chipotle Mexican Grill      59330             Food Services   
557                    Bloomin’ Brands     100000             Food Services   
562                       Hyatt Hotels      45000  Hotels, Casinos, Resorts   
585                       Wynn Resorts      20800  Hotels, Casinos, Resorts   
731              Brinker International      53000             Food Services   
763   Cracker Barrel Old Country Store      72000             Food Services   
764               Penn National Gaming      18204  Hotels, Casinos, Resorts   
779                   Scientific Games       8500  Hotels, Casinos, Resorts   
797                       Panera Bread      37200             Food Services   
895             Pinnacle Entertainment      14726  Hotels, Casinos, Resorts   
915                     Domino’s Pizza      11900             Food Services   
918                        Boyd Gaming      18243  Hotels, Casinos, Resorts   
941                 Cheesecake Factory      37600             Food Services   
999                            Wendy’s      21200             Food Services   

                 Location  Profits  Revenue  
Rank                                         
109         Oak Brook, IL     4529    25413  
146           Seattle, WA     2757    19163  
195          Bethesda, MD      859    14486  
218        Louisville, KY     1293    13105  
241         Las Vegas, NV     1966    11689  
254            McLean, VA     1404    11272  
309         Las Vegas, NV     -448     9190  
371           Orlando, FL      710     7164  
444          Stamford, CT      489     5763  
466        Parsippany, NJ      612     5536  
534         Las Vegas, NV     5920     4654  
546            Denver, CO      476     4501  
557             Tampa, FL      127     4378  
562           Chicago, IL      124     4328  
585         Las Vegas, NV      195     4076  
731            Dallas, TX      197     3002  
763           Lebanon, TN      164     2842  
764        Wyomissing, PA        1     2838  
779         Las Vegas, NV    -1394     2759  
797         St. Louis, MO      149     2682  
895         Las Vegas, NV       49     2292  
915         Ann Arbor, MI      193     2217  
918         Las Vegas, NV       47     2199  
941   Calabasas Hills, CA      117     2101  
999            Dublin, OH      161     1896  

In [56]:
# Get Company in alphabetical order (first and last)
sectors.max() 
sectors.min()
sectors.sum() # only numbers --> sectors.get_group('Apparel')['Revenue'].sum()
sectors.mean()


Out[56]:
Revenue Profits Employees
Sector
Aerospace & Defense 17897.000000 1437.100000 48402.850000
Apparel 6397.866667 549.066667 23093.133333
Business Services 5337.156863 553.470588 26687.254902
Chemicals 8129.900000 754.266667 15455.033333
Energy 12441.057377 -602.024590 9745.303279
Engineering & Construction 5922.423077 204.000000 15642.615385
Financials 15950.784173 1872.007194 24172.287770
Food and Drug Stores 32251.266667 1117.266667 93026.533333
Food, Beverages & Tobacco 12929.465116 1195.744186 28177.488372
Health Care 21529.426667 1414.853333 35710.520000
Hotels, Resturants & Leisure 6781.840000 827.880000 99369.800000
Household Products 8383.464286 515.285714 23072.785714
Industrials 10816.978261 451.391304 33591.934783
Materials 6026.627907 102.976744 14840.069767
Media 8830.560000 973.880000 22012.560000
Motor Vehicles & Parts 20105.833333 1079.083333 45106.666667
Retailing 18313.450000 597.875000 77845.362500
Technology 13505.882353 1769.343137 35087.735294
Telecommunications 30788.933333 3242.466667 55497.866667
Transportation 11347.444444 1226.916667 42688.694444
Wholesalers 11120.000000 205.825000 13139.925000

In [58]:
# Series --> Sum for each sector of all the revenues
sectors['Revenue'].sum()


Out[58]:
Sector
Aerospace & Defense              357940
Apparel                           95968
Business Services                272195
Chemicals                        243897
Energy                          1517809
Engineering & Construction       153983
Financials                      2217159
Food and Drug Stores             483769
Food, Beverages & Tobacco        555967
Health Care                     1614707
Hotels, Resturants & Leisure     169546
Household Products               234737
Industrials                      497581
Materials                        259145
Media                            220764
Motor Vehicles & Parts           482540
Retailing                       1465076
Technology                      1377600
Telecommunications               461834
Transportation                   408508
Wholesalers                      444800
Name: Revenue, dtype: int64

In [63]:
sectors['Revenue'].max() # max, min, mean


Out[63]:
Sector
Aerospace & Defense              96114
Apparel                          30601
Business Services                19330
Chemicals                        48778
Energy                          246204
Engineering & Construction       18114
Financials                      210821
Food and Drug Stores            153290
Food, Beverages & Tobacco        67702
Health Care                     181241
Hotels, Resturants & Leisure     25413
Household Products               78756
Industrials                     140389
Materials                        22534
Media                            52465
Motor Vehicles & Parts          152356
Retailing                       482130
Technology                      233715
Telecommunications              146801
Transportation                   58363
Wholesalers                      48681
Name: Revenue, dtype: int64

In [64]:
sectors[['Revenue', 'Employees']].sum()


Out[64]:
Revenue Employees
Sector
Aerospace & Defense 357940 968057
Apparel 95968 346397
Business Services 272195 1361050
Chemicals 243897 463651
Energy 1517809 1188927
Engineering & Construction 153983 406708
Financials 2217159 3359948
Food and Drug Stores 483769 1395398
Food, Beverages & Tobacco 555967 1211632
Health Care 1614707 2678289
Hotels, Resturants & Leisure 169546 2484245
Household Products 234737 646038
Industrials 497581 1545229
Materials 259145 638123
Media 220764 550314
Motor Vehicles & Parts 482540 1082560
Retailing 1465076 6227629
Technology 1377600 3578949
Telecommunications 461834 832468
Transportation 408508 1536793
Wholesalers 444800 525597

Group By with multiple Columns


In [66]:
sectors = data.groupby(['Sector', 'Industry'])

In [69]:
# Double Index
sectors.size()


Out[69]:
Sector                      Industry                                      
Aerospace & Defense         Aerospace and Defense                             20
Apparel                     Apparel                                           15
Business Services           Advertising, marketing                             2
                            Diversified Outsourcing Services                  14
                            Education                                          3
                            Financial Data Services                           19
                            Miscellaneous                                      3
                            Temporary Help                                     5
                            Waste Management                                   5
Chemicals                   Chemicals                                         30
Energy                      Energy                                            14
                            Mining, Crude-Oil Production                      28
                            Miscellaneous                                      1
                            Oil and Gas Equipment, Services                    9
                            Petroleum Refining                                17
                            Pipelines                                         12
                            Utilities: Gas and Electric                       41
Engineering & Construction  Engineering, Construction                         14
                            Homebuilders                                      12
Financials                  Commercial Banks                                  28
                            Diversified Financials                            15
                            Insurance: Life, Health (Mutual)                  10
                            Insurance: Life, Health (stock)                   18
                            Insurance: Property and Casualty (Mutual)          7
                            Insurance: Property and Casualty (Stock)          28
                            Real estate                                       15
                            Securities                                        18
Food and Drug Stores        Food and Drug Stores                              15
Food, Beverages & Tobacco   Beverages                                          9
                            Food Consumer Products                            20
                                                                              ..
Materials                   Metals                                            14
                            Miscellaneous                                      1
                            Packaging, Containers                             16
Media                       Entertainment                                     18
                            Publishing, Printing                               7
Motor Vehicles & Parts      Motor Vehicles and Parts                          24
Retailing                   Automotive Retailing, Services                    10
                            General Merchandisers                             10
                            Specialty Retailers: Apparel                      18
                            Specialty Retailers: Other                        42
Technology                  Computer Peripherals                               4
                            Computer Software                                 14
                            Computers, Office Equipment                        7
                            Information Technology Services                   13
                            Internet Services and Retailing                   15
                            Network and Other Communications Equipment        14
                            Scientific,Photographic and Control Equipment     12
                            Semiconductors and Other Electronic Components    23
Telecommunications          Telecommunications                                15
Transportation              Airlines                                           9
                            Mail, Package, and Freight Delivery                2
                            Miscellaneous                                      1
                            Railroads                                          5
                            Transportation Equipment                           5
                            Transportation and Logistics                       5
                            Trucking, Truck Leasing                            9
Wholesalers                 Miscellaneous                                      1
                            Wholesalers: Diversified                          25
                            Wholesalers: Electronics and Office Equipment      8
                            Wholesalers: Food and Grocery                      6
Length: 79, dtype: int64

In [71]:
sectors.sum() # --> MultiIndex DataFrame


Out[71]:
Revenue Profits Employees
Sector Industry
Aerospace & Defense Aerospace and Defense 357940 28742 968057
Apparel Apparel 95968 8236 346397
Business Services Advertising, marketing 22748 1549 124100
Diversified Outsourcing Services 64829 4305 708330
Education 7485 69 46755
Financial Data Services 100778 17456 264926
Miscellaneous 11185 2130 37720
Temporary Help 34716 1000 60020
Waste Management 30454 1718 119199
Chemicals Chemicals 243897 22628 463651
Energy Energy 67749 -13038 70072
Mining, Crude-Oil Production 176435 -124555 149110
Miscellaneous 3159 476 6700
Oil and Gas Equipment, Services 82827 -4047 225795
Petroleum Refining 705472 31888 244880
Pipelines 138756 5814 72141
Utilities: Gas and Electric 343411 30015 420229
Engineering & Construction Engineering, Construction 99774 1765 368104
Homebuilders 54209 3539 38604
Financials Commercial Banks 623669 129760 1539024
Diversified Financials 327075 28548 329114
Insurance: Life, Health (Mutual) 181336 5601 58801
Insurance: Life, Health (stock) 245551 19731 202233
Insurance: Property and Casualty (Mutual) 143682 8031 133148
Insurance: Property and Casualty (Stock) 548027 44803 794123
Real estate 62748 9480 160579
Securities 85071 14255 142926
Food and Drug Stores Food and Drug Stores 483769 16759 1395398
Food, Beverages & Tobacco Beverages 79396 11698 199107
Food Consumer Products 238954 19263 665439
... ... ... ... ...
Materials Metals 99925 -2241 193559
Miscellaneous 6070 7 52
Packaging, Containers 105965 4445 333446
Media Entertainment 186276 25686 383564
Publishing, Printing 34488 -1339 166750
Motor Vehicles & Parts Motor Vehicles and Parts 482540 25898 1082560
Retailing Automotive Retailing, Services 113823 2550 174974
General Merchandisers 684320 20137 3408100
Specialty Retailers: Apparel 122975 4583 770543
Specialty Retailers: Other 543958 20560 1874012
Technology Computer Peripherals 48950 3975 175259
Computer Software 179112 26457 388796
Computers, Office Equipment 353781 58433 468085
Information Technology Services 166067 16402 985639
Internet Services and Retailing 259136 22232 430855
Network and Other Communications Equipment 125697 18907 299310
Scientific,Photographic and Control Equipment 65832 9346 231501
Semiconductors and Other Electronic Components 179025 24721 599504
Telecommunications Telecommunications 461834 48637 832468
Transportation Airlines 158948 23800 391601
Mail, Package, and Freight Delivery 105816 5894 664275
Miscellaneous 2148 227 4200
Railroads 48554 9005 121844
Transportation Equipment 23855 2438 59726
Transportation and Logistics 33237 895 124691
Trucking, Truck Leasing 35950 1910 170456
Wholesalers Miscellaneous 8982 17 9200
Wholesalers: Diversified 176138 5193 233831
Wholesalers: Electronics and Office Equipment 147906 1857 166661
Wholesalers: Food and Grocery 111774 1166 115905

79 rows × 3 columns


In [72]:
sectors['Revenue'].sum()


Out[72]:
Sector                      Industry                                      
Aerospace & Defense         Aerospace and Defense                             357940
Apparel                     Apparel                                            95968
Business Services           Advertising, marketing                             22748
                            Diversified Outsourcing Services                   64829
                            Education                                           7485
                            Financial Data Services                           100778
                            Miscellaneous                                      11185
                            Temporary Help                                     34716
                            Waste Management                                   30454
Chemicals                   Chemicals                                         243897
Energy                      Energy                                             67749
                            Mining, Crude-Oil Production                      176435
                            Miscellaneous                                       3159
                            Oil and Gas Equipment, Services                    82827
                            Petroleum Refining                                705472
                            Pipelines                                         138756
                            Utilities: Gas and Electric                       343411
Engineering & Construction  Engineering, Construction                          99774
                            Homebuilders                                       54209
Financials                  Commercial Banks                                  623669
                            Diversified Financials                            327075
                            Insurance: Life, Health (Mutual)                  181336
                            Insurance: Life, Health (stock)                   245551
                            Insurance: Property and Casualty (Mutual)         143682
                            Insurance: Property and Casualty (Stock)          548027
                            Real estate                                        62748
                            Securities                                         85071
Food and Drug Stores        Food and Drug Stores                              483769
Food, Beverages & Tobacco   Beverages                                          79396
                            Food Consumer Products                            238954
                                                                               ...  
Materials                   Metals                                             99925
                            Miscellaneous                                       6070
                            Packaging, Containers                             105965
Media                       Entertainment                                     186276
                            Publishing, Printing                               34488
Motor Vehicles & Parts      Motor Vehicles and Parts                          482540
Retailing                   Automotive Retailing, Services                    113823
                            General Merchandisers                             684320
                            Specialty Retailers: Apparel                      122975
                            Specialty Retailers: Other                        543958
Technology                  Computer Peripherals                               48950
                            Computer Software                                 179112
                            Computers, Office Equipment                       353781
                            Information Technology Services                   166067
                            Internet Services and Retailing                   259136
                            Network and Other Communications Equipment        125697
                            Scientific,Photographic and Control Equipment      65832
                            Semiconductors and Other Electronic Components    179025
Telecommunications          Telecommunications                                461834
Transportation              Airlines                                          158948
                            Mail, Package, and Freight Delivery               105816
                            Miscellaneous                                       2148
                            Railroads                                          48554
                            Transportation Equipment                           23855
                            Transportation and Logistics                       33237
                            Trucking, Truck Leasing                            35950
Wholesalers                 Miscellaneous                                       8982
                            Wholesalers: Diversified                          176138
                            Wholesalers: Electronics and Office Equipment     147906
                            Wholesalers: Food and Grocery                     111774
Name: Revenue, Length: 79, dtype: int64

Aggregation Method


In [74]:
sectors = data.groupby('Sector')

In [78]:
# On selected column apply function
sectors.agg({'Revenue': 'sum', 
             'Profits': 'sum',
             'Employees': 'mean'
            })


Out[78]:
Employees Profits Revenue
Sector
Aerospace & Defense 48402.850000 28742 357940
Apparel 23093.133333 8236 95968
Business Services 26687.254902 28227 272195
Chemicals 15455.033333 22628 243897
Energy 9745.303279 -73447 1517809
Engineering & Construction 15642.615385 5304 153983
Financials 24172.287770 260209 2217159
Food and Drug Stores 93026.533333 16759 483769
Food, Beverages & Tobacco 28177.488372 51417 555967
Health Care 35710.520000 106114 1614707
Hotels, Resturants & Leisure 99369.800000 20697 169546
Household Products 23072.785714 14428 234737
Industrials 33591.934783 20764 497581
Materials 14840.069767 4428 259145
Media 22012.560000 24347 220764
Motor Vehicles & Parts 45106.666667 25898 482540
Retailing 77845.362500 47830 1465076
Technology 35087.735294 180473 1377600
Telecommunications 55497.866667 48637 461834
Transportation 42688.694444 44169 408508
Wholesalers 13139.925000 8233 444800

In [82]:
# For each columns apply all
sectors.agg(['size', 'sum', 'mean'])


Out[82]:
Revenue Profits Employees
size sum mean size sum mean size sum mean
Sector
Aerospace & Defense 20 357940 17897.000000 20 28742 1437.100000 20 968057 48402.850000
Apparel 15 95968 6397.866667 15 8236 549.066667 15 346397 23093.133333
Business Services 51 272195 5337.156863 51 28227 553.470588 51 1361050 26687.254902
Chemicals 30 243897 8129.900000 30 22628 754.266667 30 463651 15455.033333
Energy 122 1517809 12441.057377 122 -73447 -602.024590 122 1188927 9745.303279
Engineering & Construction 26 153983 5922.423077 26 5304 204.000000 26 406708 15642.615385
Financials 139 2217159 15950.784173 139 260209 1872.007194 139 3359948 24172.287770
Food and Drug Stores 15 483769 32251.266667 15 16759 1117.266667 15 1395398 93026.533333
Food, Beverages & Tobacco 43 555967 12929.465116 43 51417 1195.744186 43 1211632 28177.488372
Health Care 75 1614707 21529.426667 75 106114 1414.853333 75 2678289 35710.520000
Hotels, Resturants & Leisure 25 169546 6781.840000 25 20697 827.880000 25 2484245 99369.800000
Household Products 28 234737 8383.464286 28 14428 515.285714 28 646038 23072.785714
Industrials 46 497581 10816.978261 46 20764 451.391304 46 1545229 33591.934783
Materials 43 259145 6026.627907 43 4428 102.976744 43 638123 14840.069767
Media 25 220764 8830.560000 25 24347 973.880000 25 550314 22012.560000
Motor Vehicles & Parts 24 482540 20105.833333 24 25898 1079.083333 24 1082560 45106.666667
Retailing 80 1465076 18313.450000 80 47830 597.875000 80 6227629 77845.362500
Technology 102 1377600 13505.882353 102 180473 1769.343137 102 3578949 35087.735294
Telecommunications 15 461834 30788.933333 15 48637 3242.466667 15 832468 55497.866667
Transportation 36 408508 11347.444444 36 44169 1226.916667 36 1536793 42688.694444
Wholesalers 40 444800 11120.000000 40 8233 205.825000 40 525597 13139.925000

In [83]:
# Mixing
# On selected column apply function
sectors.agg({'Revenue': ['sum', 'mean'],
             'Profits': 'sum',
             'Employees': 'mean'
            })


Out[83]:
Employees Profits Revenue
mean sum sum mean
Sector
Aerospace & Defense 48402.850000 28742 357940 17897.000000
Apparel 23093.133333 8236 95968 6397.866667
Business Services 26687.254902 28227 272195 5337.156863
Chemicals 15455.033333 22628 243897 8129.900000
Energy 9745.303279 -73447 1517809 12441.057377
Engineering & Construction 15642.615385 5304 153983 5922.423077
Financials 24172.287770 260209 2217159 15950.784173
Food and Drug Stores 93026.533333 16759 483769 32251.266667
Food, Beverages & Tobacco 28177.488372 51417 555967 12929.465116
Health Care 35710.520000 106114 1614707 21529.426667
Hotels, Resturants & Leisure 99369.800000 20697 169546 6781.840000
Household Products 23072.785714 14428 234737 8383.464286
Industrials 33591.934783 20764 497581 10816.978261
Materials 14840.069767 4428 259145 6026.627907
Media 22012.560000 24347 220764 8830.560000
Motor Vehicles & Parts 45106.666667 25898 482540 20105.833333
Retailing 77845.362500 47830 1465076 18313.450000
Technology 35087.735294 180473 1377600 13505.882353
Telecommunications 55497.866667 48637 461834 30788.933333
Transportation 42688.694444 44169 408508 11347.444444
Wholesalers 13139.925000 8233 444800 11120.000000

In [84]:
aggregated = sectors.agg({'Revenue': ['sum', 'mean'],
             'Profits': 'sum',
             'Employees': 'mean'
            })

In [97]:
aggregated.loc['Apparel']


Out[97]:
Employees  mean    23093.133333
Profits    sum      8236.000000
Revenue    sum     95968.000000
           mean     6397.866667
Name: Apparel, dtype: float64

In [93]:
aggregated['Revenue']['sum']


Out[93]:
Sector
Aerospace & Defense              357940
Apparel                           95968
Business Services                272195
Chemicals                        243897
Energy                          1517809
Engineering & Construction       153983
Financials                      2217159
Food and Drug Stores             483769
Food, Beverages & Tobacco        555967
Health Care                     1614707
Hotels, Resturants & Leisure     169546
Household Products               234737
Industrials                      497581
Materials                        259145
Media                            220764
Motor Vehicles & Parts           482540
Retailing                       1465076
Technology                      1377600
Telecommunications               461834
Transportation                   408508
Wholesalers                      444800
Name: sum, dtype: int64

Iteration through Groups


In [116]:
data = pd.read_csv('data/fortune1000.csv', index_col='Rank')
sectors = data.groupby('Sector')
data.head()


Out[116]:
Company Sector Industry Location Revenue Profits Employees
Rank
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
2 Exxon Mobil Energy Petroleum Refining Irving, TX 246204 16150 75600
3 Apple Technology Computers, Office Equipment Cupertino, CA 233715 53394 110000
4 Berkshire Hathaway Financials Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
5 McKesson Health Care Wholesalers: Health Care San Francisco, CA 181241 1476 70400

In [117]:
# new dataframe, used to store data
df = pd.DataFrame(columns=data.columns)
df


Out[117]:
Company Sector Industry Location Revenue Profits Employees

In [118]:
# highest revenue for each sector

In [119]:
for sector, value in sectors:
    highest_revenue_company_in_group = value.nlargest(1, 'Revenue')
    df = df.append(highest_revenue_company_in_group)

In [120]:
df


Out[120]:
Company Sector Industry Location Revenue Profits Employees
24 Boeing Aerospace & Defense Aerospace and Defense Chicago, IL 96114 5176 161400
91 Nike Apparel Apparel Beaverton, OR 30601 3273 62600
144 ManpowerGroup Business Services Temporary Help Milwaukee, WI 19330 419 27000
56 Dow Chemical Chemicals Chemicals Midland, MI 48778 7685 49495
2 Exxon Mobil Energy Petroleum Refining Irving, TX 246204 16150 75600
155 Fluor Engineering & Construction Engineering, Construction Irving, TX 18114 413 38758
4 Berkshire Hathaway Financials Insurance: Property and Casualty (Stock) Omaha, NE 210821 24083 331000
7 CVS Health Food and Drug Stores Food and Drug Stores Woonsocket, RI 153290 5237 199000
41 Archer Daniels Midland Food, Beverages & Tobacco Food Production Chicago, IL 67702 1849 32300
5 McKesson Health Care Wholesalers: Health Care San Francisco, CA 181241 1476 70400
109 McDonald’s Hotels, Resturants & Leisure Food Services Oak Brook, IL 25413 4529 420000
34 Procter & Gamble Household Products Household and Personal Products Cincinnati, OH 78756 7036 110000
11 General Electric Industrials Industrial Machinery Fairfield, CT 140389 -6126 333000
126 Alcoa Materials Metals New York, NY 22534 -322 60000
53 Disney Media Entertainment Burbank, CA 52465 8382 185000
8 General Motors Motor Vehicles & Parts Motor Vehicles and Parts Detroit, MI 152356 9687 215000
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
3 Apple Technology Computers, Office Equipment Cupertino, CA 233715 53394 110000
10 AT&T Telecommunications Telecommunications Dallas, TX 146801 13345 281450
48 UPS Transportation Mail, Package, and Freight Delivery Atlanta, GA 58363 4844 341240
57 Sysco Wholesalers Wholesalers: Food and Grocery Houston, TX 48681 687 51700

In [121]:
cities = data.groupby('Location')

In [122]:
df = pd.DataFrame(columns=data.columns)
df


Out[122]:
Company Sector Industry Location Revenue Profits Employees

In [123]:
for city, value in cities:
    highest_revenue_in_city = value.nlargest(1, 'Revenue')
    df = df.append(highest_revenue_in_city)

In [124]:
df


Out[124]:
Company Sector Industry Location Revenue Profits Employees
138 Abbott Laboratories Health Care Medical Products and Equipment Abbott Park, IL 20661 4423 74000
169 Goodyear Tire & Rubber Motor Vehicles & Parts Motor Vehicles and Parts Akron, OH 16443 307 66000
288 Air Products & Chemicals Chemicals Chemicals Allentown, PA 9895 1278 19550
830 Benchmark Electronics Technology Semiconductors and Other Electronic Components Angleton, TX 2541 95 10500
374 Casey’s General Stores Retailing Specialty Retailers: Other Ankeny, IA 7052 181 22408
915 Domino’s Pizza Hotels, Resturants & Leisure Food Services Ann Arbor, MI 2217 193 11900
596 Colfax Industrials Industrial Machinery Annapolis Junction, MD 3967 168 17087
215 Land O’Lakes Food, Beverages & Tobacco Food Consumer Products Arden Hills, MN 13161 308 10000
190 AES Energy Utilities: Gas and Electric Arlington, VA 14963 306 21000
31 IBM Technology Information Technology Services Armonk, NY 82461 13190 411798
28 Home Depot Retailing Specialty Retailers: Other Atlanta, GA 88519 7009 385000
310 Autoliv Motor Vehicles & Parts Motor Vehicles and Parts Auburn Hills, MI 9170 457 59350
304 Hormel Foods Food, Beverages & Tobacco Food Consumer Products Austin, MN 9264 686 20700
181 Whole Foods Market Food and Drug Stores Food and Drug Stores Austin, TX 15389 536 76300
668 PolyOne Chemicals Chemicals Avon Lake, OH 3378 145 6900
573 T. Rowe Price Financials Securities Baltimore, MD 4201 1223 5999
420 Baxalta Health Care Pharmaceuticals Bannockburn, IL 6149 956 17000
624 Albemarle Chemicals Chemicals Baton Rouge, LA 3651 335 6963
207 Kellogg Food, Beverages & Tobacco Food Consumer Products Battle Creek, MI 13525 614 33577
91 Nike Apparel Apparel Beaverton, OR 30601 3273 62600
147 Paccar Motor Vehicles & Parts Motor Vehicles and Parts Bellevue, WA 19115 1604 23000
645 Regal Beloit Industrials Electronics, Electrical Equip. Beloit, WI 3510 143 26200
134 Whirlpool Industrials Electronics, Electrical Equip. Benton Harbor, MI 20891 783 97000
1 Walmart Retailing General Merchandisers Bentonville, AR 482130 14694 2300000
594 Ametek Technology Scientific,Photographic and Control Equipment Berwyn, PA 3974 591 15400
60 Lockheed Martin Aerospace & Defense Aerospace and Defense Bethesda, MD 46132 3605 126000
399 Cablevision Systems Telecommunications Telecommunications Bethpage, NY 6510 175 13549
366 Live Nation Entertainment Media Entertainment Beverly Hills, CA 7246 -33 12200
453 Regions Financial Financials Commercial Banks Birmingham, AL 5674 1062 23916
558 MDU Resources Group Energy Energy Bismarck, ND 4376 -622 8689
... ... ... ... ... ... ... ...
120 Raytheon Aerospace & Defense Aerospace and Defense Waltham, MA 23247 2074 61000
850 United Refining Energy Petroleum Refining Warren, PA 2470 82 2997
431 Zimmer Biomet Holdings Health Care Medical Products and Equipment Warsaw, IN 5998 147 17500
16 Fannie Mae Financials Diversified Financials Washington, DC 110359 10954 7300
542 Keurig Green Mountain Food, Beverages & Tobacco Beverages Waterbury, VT 4520 498 6000
898 MPM Holdings Chemicals Chemicals Waterford, NY 2289 -83 5000
874 Granite Construction Engineering & Construction Engineering, Construction Watsonville, CA 2371 61 3200
1000 Briggs & Stratton Industrials Industrial Machinery Wauwatosa, WI 1895 46 5480
240 Toys “R” Us Retailing Specialty Retailers: Other Wayne, NJ 11802 -130 62000
785 B/E Aerospace Aerospace & Defense Aerospace and Defense Wellington, FL 2730 286 10057
383 AK Steel Holding Materials Metals West Chester, OH 6693 -509 8500
829 Platform Specialty Products Chemicals Chemicals West Palm Beach, FL 2542 -309 8200
996 New York Community Bancorp Financials Commercial Banks Westbury, NY 1902 -47 3448
456 Ingredion Food, Beverages & Tobacco Food Production Westchester, IL 5621 402 11500
439 TravelCenters of America Retailing Specialty Retailers: Other Westlake, OH 5851 28 18450
396 Terex Industrials Construction and Farm Machinery Westport, CT 6543 146 20400
847 ITT Industrials Industrial Machinery White Plains, NY 2486 352 9700
389 Spirit AeroSystems Holdings Aerospace & Defense Aerospace and Defense Wichita, KS 6644 789 15200
849 Tops Holding Food and Drug Stores Food and Drug Stores Williamsville, NY 2472 -62 14800
674 Westinghouse Air Brake Technologies Industrials Industrial Machinery Wilmerding, PA 3308 399 13000
101 DuPont Chemicals Chemicals Wilmington, DE 27940 1953 52000
607 Fastenal Retailing Specialty Retailers: Other Winona, MN 3869 516 20746
266 Reynolds American Food, Beverages & Tobacco Tobacco Winston-Salem, NC 10675 3253 5650
678 Skyworks Solutions Technology Semiconductors and Other Electronic Components Woburn, MA 3258 798 6700
172 Health Net Health Care Health Care: Insurance and Managed Care Woodland Hills, CA 16244 186 8584
7 CVS Health Food and Drug Stores Food and Drug Stores Woonsocket, RI 153290 5237 199000
506 Hanover Insurance Group Financials Insurance: Property and Casualty (Stock) Worcester, MA 5034 332 4800
764 Penn National Gaming Hotels, Resturants & Leisure Hotels, Casinos, Resorts Wyomissing, PA 2838 1 18204
773 Bon-Ton Stores Retailing General Merchandisers York, PA 2790 -57 24100
932 Herman Miller Household Products Home Equipment, Furnishings Zeeland, MI 2142 98 7510

416 rows × 7 columns


In [ ]:


In [ ]: