In [107]:
import pandas as pd

In [108]:
import matplotlib.pyplot as plt

In [109]:
%matplotlib inline

In [18]:
df = pd.read_csv("07-hw-animals.csv")
print(df)


  animal        name  length
0    cat        Anne      35
1    cat         Bob      45
2    dog  Egglesburg      65
3    dog       Devon      50
4    cat     Charlie      32
5    dog    Fontaine      35

In [10]:
print(df.columns.values)


['animal' 'name' 'length']

In [13]:
print(df['animal'])


0    cat
1    cat
2    dog
3    dog
4    cat
5    dog
Name: animal, dtype: object

In [19]:
print(df[:3])


  animal        name  length
0    cat        Anne      35
1    cat         Bob      45
2    dog  Egglesburg      65

In [27]:
print(df)


  animal        name  length
0    cat        Anne      35
1    cat         Bob      45
2    dog  Egglesburg      65
3    dog       Devon      50
4    cat     Charlie      32
5    dog    Fontaine      35

In [32]:
print(df.sort_values(by='length', ascending=0)[:3])


  animal        name  length
2    dog  Egglesburg      65
3    dog       Devon      50
1    cat         Bob      45

In [45]:
print(df['animal'])


0    cat
1    cat
2    dog
3    dog
4    cat
5    dog
Name: animal, dtype: object

In [66]:
print(df['animal'].value_counts())


cat    3
dog    3
Name: animal, dtype: int64

In [77]:
dogs = df[df['animal'] == 'dog']
dogs


Out[77]:
animal name length
2 dog Egglesburg 65
3 dog Devon 50
5 dog Fontaine 35

In [78]:
df[df['length'] > 40]


Out[78]:
animal name length
1 cat Bob 45
2 dog Egglesburg 65
3 dog Devon 50

In [81]:
df['inches'] = df['length'] * .394
df


Out[81]:
animal name length inches
0 cat Anne 35 13.790
1 cat Bob 45 17.730
2 dog Egglesburg 65 25.610
3 dog Devon 50 19.700
4 cat Charlie 32 12.608
5 dog Fontaine 35 13.790

In [90]:
cats = df[df['animal'] == 'cat']
cats


Out[90]:
animal name length inches
0 cat Anne 35 13.790
1 cat Bob 45 17.730
4 cat Charlie 32 12.608

In [91]:
dogs = df[df['animal'] == 'dog']
dogs


Out[91]:
animal name length inches
2 dog Egglesburg 65 25.61
3 dog Devon 50 19.70
5 dog Fontaine 35 13.79

In [92]:
cats[cats['inches'] > 12]


Out[92]:
animal name length inches
0 cat Anne 35 13.790
1 cat Bob 45 17.730
4 cat Charlie 32 12.608

In [99]:
df[df['inches'] > 12]
df[df['animal'] == 'cat']
#another way: df[(df['animal'] == 'cat') & (df['inches'] > 12)]


Out[99]:
animal name length inches
0 cat Anne 35 13.790
1 cat Bob 45 17.730
4 cat Charlie 32 12.608

In [103]:
cats['length'].mean()
#see also: cats['length'].describe()


Out[103]:
37.333333333333336

In [104]:
dogs['length'].mean()


Out[104]:
50.0

In [105]:
df.groupby('animal')['length'].mean()


Out[105]:
animal
cat    37.333333
dog    50.000000
Name: length, dtype: float64

In [110]:
dogs['length'].hist()


Out[110]:
<matplotlib.axes._subplots.AxesSubplot at 0x6103910>

In [111]:
dogs.plot(kind='scatter', x='length', y='inches')


Out[111]:
<matplotlib.axes._subplots.AxesSubplot at 0x6220cd0>

In [113]:
df.plot(kind='barh', x='name', y='length', legend=False)


Out[113]:
<matplotlib.axes._subplots.AxesSubplot at 0x7223bd0>

In [119]:
sortcats = (cats.sort_values(by='length', ascending=0))
sortcats.plot(kind='barh', x='name', y='length', legend=False, sort_columns=False)
#alternately! df[df['animal'] == 'cat'].sort_values(by='length').plot(kind='barh', x='name', y='length')


Out[119]:
<matplotlib.axes._subplots.AxesSubplot at 0x730ead0>

In [117]:
cats


Out[117]:
animal name length inches
0 cat Anne 35 13.790
1 cat Bob 45 17.730
4 cat Charlie 32 12.608

In [5]:
import pandas as pd
df = pd.read_excel("richpeople.xlsx")

What country are most billionaires from? For the top ones, how many billionaires per billion people? Who are the top 10 richest billionaires? What's the average wealth of a billionaire? Male? Female? Who is the poorest billionaire? Who are the top 10 poorest billionaires? 'What is relationship to company'? And what are the most common relationships? Most common source of wealth? Male vs. female? Given the richest person in a country, what % of the GDP is their wealth? Add up the wealth of all of the billionaires in a given country (or a few countries) and then compare it to the GDP of the country, or other billionaires, so like pit the US vs India What are the most common industries for billionaires to come from? What's the total amount of billionaire money from each industry? How many self made billionaires vs. others? How old are billionaires? How old are billionaires self made vs. non self made? or different industries? Who are the youngest billionaires? The oldest? Age distribution - maybe make a graph about it? Maybe just made a graph about how wealthy they are in general? Maybe plot their net worth vs age (scatterplot) Make a bar graph of the top 10 or 20 richest

How many female billionaires are there compared to male? What industries are they from? What is their average wealth?


In [13]:
import matplotlib.pyplot as plt
%matplotlib inline

In [7]:
print(df['gender'].value_counts())


male              2328
female             249
married couple       3
Name: gender, dtype: int64

In [8]:
df.groupby('gender')['networthusbillion'].mean()


Out[8]:
gender
female            3.819277
male              3.516881
married couple    1.300000
Name: networthusbillion, dtype: float64

In [10]:
df.groupby('gender')['sourceofwealth'].value_counts()


Out[10]:
gender  sourceofwealth                   
female  diversified                          9
        real estate                          7
        media                                6
        construction                         5
        consumer goods                       5
        hotels, investments                  5
        Wal-Mart                             4
        casinos                              4
        chemicals                            4
        cleaning products                    4
        Samsung                              3
        banking                              3
        commodities                          3
        mining                               3
        packaging                            3
        pipelines                            3
        retail                               3
        Campbell Soup                        2
        Cargill Inc.                         2
        bank, media                          2
        banking inheritance                  2
        coffee                               2
        financial services                   2
        hotels, restaurants                  2
        inherited, cosmetics                 2
        insurance                            2
        investments                          2
        medical equipment                    2
        paper                                2
        pharmaceuticals                      2
                                            ..
male    telecom, oil service, real estate    1
        telecom, oil, beer                   1
        telecoms                             1
        telecoms/lotteries/insurance         1
        television, Univision                1
        temp agency                          1
        textiles, apparel                    1
        timber/media                         1
        timberland, lumber mills             1
        tobacco                              1
        tobacco distribution, retail         1
        tobacco, banking                     1
        tools                                1
        tourism, construction                1
        tractors                             1
        trading company                      1
        transport                            1
        travel                               1
        vaccines                             1
        vacuums                              1
        venture capital, Google              1
        video cameras                        1
        videogames                           1
        water                                1
        water treatment systems              1
        web hosting                          1
        wind turbines                        1
        wine                                 1
        winter jackets                       1
        wrestling                            1
Name: sourceofwealth, dtype: int64

Some examples from the review


In [16]:
df.columns.values
df['countrycode'].value_counts()


Out[16]:
USA       903
DEU       160
CHN       153
RUS       119
JPN        96
BRA        81
HKG        77
FRA        72
GBR        65
IND        63
ITA        58
CAN        53
CHE        51
MEX        44
Taiwan     40
ESP        37
KOR        36
AUS        33
TUR        32
IDN        31
MYS        28
SWE        27
ISR        26
SGP        26
THA        23
SAU        22
PHL        22
CHL        19
ARG        12
ZAF        12
         ... 
FIN         5
ARE         5
POL         5
PRT         5
KAZ         5
BEL         4
CYP         4
DNK         4
NGA         4
MAR         4
MCO         3
NZL         3
OMN         2
MAC         2
LIE         2
UGA         1
ECU         1
TZA         1
KNA         1
VNM         1
DZA         1
ROU         1
SWZ         1
BHR         1
BMU         1
AGO         1
NPL         1
LTU         1
GGY         1
GEO         1
Name: countrycode, dtype: int64

In [19]:
df.sort_values(by='networthusbillion', ascending=False).head(10)


Out[19]:
year name rank citizenship countrycode networthusbillion selfmade typeofwealth gender age ... relationshiptocompany foundingdate gdpcurrentus sourceofwealth notes notes2 source source_2 source_3 source_4
284 2014 Bill Gates 1 United States USA 76.0 self-made founder non-finance male 58.0 ... founder 1975.0 NaN Microsoft NaN NaN http://www.forbes.com/profile/bill-gates/ NaN NaN NaN
348 2014 Carlos Slim Helu 2 Mexico MEX 72.0 self-made privatized and resources male 74.0 ... founder 1990.0 NaN telecom NaN NaN http://www.ozy.com/provocateurs/carlos-slims-w... NaN NaN NaN
124 2014 Amancio Ortega 3 Spain ESP 64.0 self-made founder non-finance male 77.0 ... founder 1975.0 NaN retail NaN NaN http://www.forbes.com/profile/amancio-ortega/ NaN NaN NaN
283 2001 Bill Gates 1 United States USA 58.7 self-made founder non-finance male 45.0 ... founder 1975.0 1.062180e+13 NaN NaN NaN http://www.forbes.com/profile/bill-gates/ NaN NaN NaN
2491 2014 Warren Buffett 4 United States USA 58.2 self-made founder non-finance male 83.0 ... founder 1839.0 NaN Berkshire Hathaway NaN NaN http://www.forbes.com/lists/2009/10/billionair... http://www.forbes.com/companies/berkshire-hath... NaN NaN
1377 2014 Larry Ellison 5 United States USA 48.0 self-made founder non-finance male 69.0 ... founder 1977.0 NaN Oracle NaN NaN http://www.forbes.com/profile/larry-ellison/ http://www.businessinsider.com/how-larry-ellis... NaN NaN
509 2014 David Koch 6 United States USA 40.0 inherited inherited male 73.0 ... relation 1940.0 NaN diversified inherited from father NaN http://www.kochind.com/About_Koch/History_Time... NaN NaN NaN
381 2014 Charles Koch 6 United States USA 40.0 inherited inherited male 78.0 ... relation 1940.0 NaN diversified inherited from father NaN http://www.kochind.com/About_Koch/History_Time... NaN NaN NaN
2185 2014 Sheldon Adelson 8 United States USA 38.0 self-made self-made finance male 80.0 ... founder 1952.0 NaN casinos NaN NaN http://www.forbes.com/profile/sheldon-adelson/ http://lasvegassun.com/news/1996/nov/26/rat-pa... NaN NaN
429 2014 Christy Walton 9 United States USA 36.7 inherited inherited female 59.0 ... relation 1962.0 NaN Wal-Mart widow NaN http://www.forbes.com/profile/christy-walton/ NaN NaN NaN

10 rows × 30 columns


In [21]:
#Who is the poorest billionaire? Top ten poorest?
df.sort_values(by='rank', ascending=False).head(2)


Out[21]:
year name rank citizenship countrycode networthusbillion selfmade typeofwealth gender age ... relationshiptocompany foundingdate gdpcurrentus sourceofwealth notes notes2 source source_2 source_3 source_4
990 2014 Ina Chan 1565 Hong Kong HKG 1.0 inherited inherited female 60.0 ... relation 1962.0 NaN casinos 3rd wife NaN http://www.forbes.com/profile/ina-chan/ NaN NaN NaN
358 2014 Chang Pyung-Soon 1565 South Korea KOR 1.0 self-made founder non-finance male 63.0 ... founder 1985.0 NaN education NaN NaN http://www.forbes.com/profile/chang-pyung-soon/ http://www.bloomberg.com/research/stocks/priva... NaN NaN

2 rows × 30 columns


In [22]:
df[df['networthusbillion'] == 1]


Out[22]:
year name rank citizenship countrycode networthusbillion selfmade typeofwealth gender age ... relationshiptocompany foundingdate gdpcurrentus sourceofwealth notes notes2 source source_2 source_3 source_4
4 1996 Abdul Aziz Al-Sulaiman 404 Saudi Arabia SAU 1.0 self-made self-made finance male 0.0 ... founder 1968.0 1.577430e+11 NaN NaN NaN http://www.arabianbusiness.com/arabian-busines... NaN NaN NaN
19 1996 Adolf Merckle 388 Germany DEU 1.0 inherited inherited male 61.0 ... relation 1881.0 2.500000e+12 NaN 4th generation NaN NaN NaN NaN NaN
24 1996 Ahmed Ali Kanoo 383 Bahrain BHR 1.0 inherited inherited male 0.0 ... relation 1890.0 6.100000e+09 NaN 3rd generation With the permission and support of past Bahrai... http://www.gulf-daily-news.com/NewsDetails.asp... http://en.wikipedia.org/wiki/Yusuf_Bin_Ahmed_K... NaN NaN
49 2001 Albert Frere 490 Belgium BEL 1.0 self-made self-made finance male 75.0 ... founder 1956.0 2.370000e+11 NaN NaN NaN http://en.wikipedia.org/wiki/Albert_Fr%C3%A8re http://www.economist.com/node/6823579 NaN NaN
56 2014 Alberto Alcocer 1565 Spain ESP 1.0 self-made self-made finance male 71.0 ... owner 1952.0 NaN investments married to Esther Koplowitz NaN http://en.wikipedia.org/wiki/Alberto_Alcocer http://www.forbes.com/profile/alberto-alcocer/ NaN NaN
63 2001 Alberto Vilar 490 United States USA 1.0 self-made self-made finance male NaN ... founder 1980.0 1.062180e+13 NaN convicted for money laundering and fraud in 2008 NaN http://en.wikipedia.org/wiki/Alberto_Vilar ARTS AND THE MAN The Miami Herald June 17, 200... http://money.cnn.com/2005/05/27/news/newsmaker... NaN
81 2014 Alexander Vik 1565 Norway NOR 1.0 self-made self-made finance male 59.0 ... investor 1980.0 NaN investments many business ventures have failed but still m... NaN http://www.forbes.com/sites/nathanvardi/2014/0... NaN NaN NaN
107 1996 Alicia and Esther Koplowitz 405 Spain ESP 1.0 inherited inherited female 0.0 ... relation 1952.0 6.410000e+11 NaN inherited from father fortune split between her and sister http://en.wikipedia.org/wiki/Alicia_Koplowitz,... http://www.forbes.com/profile/alicia-koplowitz/ NaN NaN
108 2001 Alicia Koplowitz 490 Spain ESP 1.0 inherited inherited female 48.0 ... relation 1952.0 6.260000e+11 NaN inherited from father fortune split between her and sister http://en.wikipedia.org/wiki/Alicia_Koplowitz,... http://www.forbes.com/profile/alicia-koplowitz/ NaN NaN
122 2001 Amalia Lacroze de Fortabat 490 Argentina ARG 1.0 inherited inherited female NaN ... relation 1926.0 2.690000e+11 NaN widow NaN http://en.wikipedia.org/wiki/Mar%C3%ADa_Amalia... Australian Financial Review February 28, 2014 ... NaN NaN
129 2014 An Kang 1565 China CHN 1.0 self-made founder non-finance male 65.0 ... founder 1992.0 NaN pharmaceuticals NaN NaN http://www.forbes.com/profile/an-kang/ http://english.hualanbio.com/enterhualan/history/ NaN NaN
131 1996 Ana Maria Brescia Cafferata 401 Peru PER 1.0 inherited inherited female 0.0 ... relation 1889.0 5.397591e+10 NaN inherited father's company took part in major business decisions of company http://es.wikipedia.org/wiki/Grupo_Brescia http://www.forbes.com/profile/ana-maria-bresci... NaN NaN
136 2001 Ananda Krishnan 490 Malaysia MYS 1.0 self-made founder non-finance male 62.0 ... founder 1984.0 9.278395e+10 NaN NaN NaN http://en.wikipedia.org/wiki/Ananda_Krishnan http://www.bloomberg.com/research/stocks/priva... http://www.forbes.com/profile/ananda-krishnan/ NaN
145 2014 Andrea Reimann-Ciardelli 1565 United States USA 1.0 inherited inherited female NaN ... relation 1923.0 NaN consumer goods inherited from father no involvement in company http://www.forbes.com/profile/matthias-reimann... NaN NaN NaN
164 2014 Andrew Gotianun 1565 Philippines PHL 1.0 self-made self-made finance male 86.0 ... founder 1955.0 NaN real estate NaN NaN http://en.wikipedia.org/wiki/Andrew_Gotianun http://www.forbes.com/profile/andrew-gotianun/ Second-hand car dealer discovers road to riche... NaN
171 2014 Angela Bennett 1565 Australia AUS 1.0 inherited inherited female 69.0 ... relation 1955.0 NaN mining inherited from father shared fortune with brother http://www.forbes.com/profile/angela-bennett/ NaN NaN NaN
178 2014 Anne Beaufour 1565 France FRA 1.0 inherited inherited female 50.0 ... relation 1929.0 NaN pharmaceuticals 3rd generation NaN http://en.wikipedia.org/wiki/Ipsen http://www.ipsen.com/le-groupe/historique-du-g... http://www.forbes.com/profile/anne-beaufour/ NaN
191 2001 Antonia Johnson 490 Sweden SWE 1.0 inherited inherited female 57.0 ... relation 1873.0 2.399170e+11 NaN 4th generation chairman, no siblings, one female cousin http://en.wikipedia.org/wiki/Antonia_Ax:son_Jo... http://www.forbes.com/profile/antonia-johnson/ NaN NaN
223 1996 Autrey family 400 Mexico MEX 1.0 NaN NaN NaN 0.0 ... NaN NaN 3.974040e+11 NaN NaN NaN MEXICAN FAMILY ATTEMPTS A COMEBACK WALL STREET... NaN NaN NaN
234 2014 B.R. Shetty 1565 India IND 1.0 self-made founder non-finance male 72.0 ... founder 1975.0 NaN healthcare NaN NaN http://en.wikipedia.org/wiki/B._R._Shetty http://www.nmchealth.com/dr-br-shetty/ NaN NaN
247 2001 Barry Diller 490 United States USA 1.0 self-made executive male 59.0 ... Chairman and Chief Executive Officer 1986.0 1.062180e+13 NaN NaN NaN http://en.wikipedia.org/wiki/Barry_Diller http://www.forbes.com/profile/barry-diller/ VIVENDI TO ENLIST DILLER AS CO-CEO;STRUGGLING ... NaN
252 2001 Belmiro de Azevedo 490 Portugal PRT 1.0 self-made executive male 59.0 ... chairman 1959.0 1.215460e+11 NaN nationalized in 1974 and reprivitized later NaN http://en.wikipedia.org/wiki/Sonae http://www.fchampalimaud.org/en/the-foundation... NaN NaN
256 2001 Benjamin de Rothschild 490 Switzerland CHE 1.0 inherited inherited male NaN ... relation 1953.0 2.790000e+11 NaN 5th generation member of Rothschild banking family (founded i... http://en.wikipedia.org/wiki/Benjamin_de_Roths... NaN NaN NaN
261 2014 Bent Jensen 1565 Denmark DEN 1.0 inherited inherited male 62.0 ... relation 1907.0 NaN electric linear systems 3rd generation NaN http://www.forbes.com/profile/bent-jensen/ NaN NaN NaN
295 1996 Boonsong Asavabhokhin 408 Thailand THA 1.0 NaN NaN male 0.0 ... NaN NaN 1.819480e+11 NaN NaN NaN http://www.pbs.org/wgbh/pages/frontline/shows/... NaN NaN NaN
296 2014 Boris Mints 1565 Russia RUS 1.0 self-made self-made finance male 55.0 ... owner 2010.0 NaN real estate NaN NaN http://www.forbes.com/profile/boris-mints/ http://www.o1properties.ru/o1properties/about-... http://www.bloomberg.com/research/stocks/priva... NaN
302 2014 Brian Higgins 1565 United States USA 1.0 self-made self-made finance male 49.0 ... founder 1995.0 NaN Hedge fund NaN NaN http://www.forbes.com/profile/brian-higgins-1/ http://www.forbes.com/sites/nathanvardi/2014/0... NaN NaN
310 2001 Bruce Kovner 490 United States USA 1.0 self-made self-made finance male 55.0 ... founder 1983.0 1.062180e+13 NaN NaN NaN http://en.wikipedia.org/wiki/Bruce_Kovner https://www.caxton.com/ Bruce Kovner, Influential Hedge Fund Manager, ... NaN
320 2014 C. James Koch 1565 United States USA 1.0 self-made founder non-finance male 64.0 ... founder 1984.0 NaN beer NaN NaN http://en.wikipedia.org/wiki/Samuel_Adams_(beer) SAM ADAMS CREATOR THRIVES AMID CRAFT BEER SURG... NaN NaN
332 1996 Carl Pohlad 423 United States USA 1.0 self-made self-made finance male 80.0 ... owner 1920.0 8.100200e+12 NaN NaN NaN http://en.wikipedia.org/wiki/Carl_Pohlad http://www.nytimes.com/2009/01/06/sports/baseb... NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2200 1996 Shoichiro Toyoda 395 Japan JPN 1.0 inherited inherited male 0.0 ... relation 1937.0 4.710000e+12 NaN 3rd generation NaN http://en.wikipedia.org/wiki/Shoichiro_Toyoda NaN NaN NaN
2202 2001 Shoji Uehara 490 Japan JPN 1.0 inherited inherited male NaN ... relation 1912.0 4.160000e+12 NaN inherited from father NaN http://www.forbes.com/profile/shoji-uehara/# http://en.wikipedia.org/wiki/Taisho_Pharmaceut... NaN NaN
2203 2014 Shoji Uehara 1565 Japan JPN 1.0 inherited inherited male 86.0 ... relation 1912.0 NaN pharmaceuticals inherited from father NaN http://www.forbes.com/profile/shoji-uehara/# http://en.wikipedia.org/wiki/Taisho_Pharmaceut... NaN NaN
2204 1996 Shoul Eisenberg 392 Israel ISR 1.0 self-made privatized and resources male 0.0 ... founder 1968.0 1.090000e+11 NaN joint venture with governement NaN http://en.wikipedia.org/wiki/Israel_Corporation NaN NaN NaN
2247 2014 Stefan von Holtzbrinck 1565 Germany DEU 1.0 inherited inherited male 50.0 ... relation 1948.0 NaN publishing inherited from father NaN http://www.forbes.com/profile/monika-schoeller/ NaN NaN NaN
2277 1996 Steven Spielberg 422 United States USA 1.0 self-made founder non-finance male 49.0 ... founder 1994.0 8.100200e+12 NaN NaN NaN http://en.wikipedia.org/wiki/Steven_Spielberg NaN NaN NaN
2285 1996 Strwher family 389 Germany DEU 1.0 NaN NaN NaN 0.0 ... NaN NaN 2.500000e+12 NaN NaN NaN NaN NaN NaN NaN
2316 2014 T.S. Kalyanaraman 1565 India IND 1.0 self-made founder non-finance male 66.0 ... founder 1993.0 NaN jewelry NaN NaN http://en.wikipedia.org/wiki/T.S._Kalyanaraman http://www.bloomberg.com/news/articles/2013-01... NaN NaN
2358 2001 Thomas Bailey 490 United States USA 1.0 self-made self-made finance male 64.0 ... founder 1969.0 1.062180e+13 NaN NaN NaN http://en.wikipedia.org/wiki/Thomas_H._Bailey http://en.wikipedia.org/wiki/Janus_Capital_Group http://archive.fortune.com/magazines/fortune/f... NaN
2359 2014 Thomas Bailey 1565 United States USA 1.0 self-made self-made finance male 77.0 ... founder 1969.0 NaN finance NaN NaN http://en.wikipedia.org/wiki/Thomas_H._Bailey http://en.wikipedia.org/wiki/Janus_Capital_Group http://archive.fortune.com/magazines/fortune/f... NaN
2365 2014 Thomas Kaplan 1565 United States USA 1.0 self-made self-made finance male 51.0 ... founder 1993.0 NaN investments NaN NaN http://en.wikipedia.org/wiki/Thomas_Kaplan http://www.wsj.com/articles/SB1000142405270230... NaN NaN
2391 2001 Toichi Takenaka 490 Japan JPN 1.0 inherited inherited male 58.0 ... relation 1610.0 4.160000e+12 NaN 15th or more generation NaN http://en.wikipedia.org/wiki/Takenaka_Corporation NaN NaN NaN
2394 2001 Tom Gores 490 United States USA 1.0 self-made self-made finance male 36.0 ... founder 1995.0 1.062180e+13 NaN NaN NaN http://en.wikipedia.org/wiki/Tom_Gores http://en.wikipedia.org/wiki/Platinum_Equity NaN NaN
2401 2014 Tory Burch 1565 United States USA 1.0 self-made founder non-finance female 47.0 ... founder 2004.0 NaN fashion NaN NaN http://en.wikipedia.org/wiki/J._Christopher_Burch http://www.vanityfair.com/news/2007/02/tory-bu... NaN NaN
2439 2001 Vinod Khosla 490 United States USA 1.0 self-made self-made finance male 46.0 ... founder 1982.0 1.062180e+13 NaN NaN NaN http://en.wikipedia.org/wiki/Vinod_Khosla Silicon Valley billionaire likes playing a gam... NaN NaN
2443 2014 Vivek Chaand Sehgal 1565 Australia AUS 1.0 self-made founder non-finance male 57.0 ... founder 1986.0 NaN auto parts Indian founder of Motherson Sumi, Australian c... NaN http://www.forbes.com/profile/vivek-chaand-seh... http://en.wikipedia.org/wiki/Motherson_Sumi_Sy... NaN Will Vivek Sehgal’s Gambit Pay Off? Rashmi K P...
2472 2014 Wang Jianfeng 1565 China CHN 1.0 self-made founder non-finance male 44.0 ... founder 2004.0 NaN auto parts NaN NaN http://www.forbes.com/profile/wang-jianfeng/ http://en.joyson.cn/About/RongYuZiZHi.html NaN NaN
2479 2014 Wang Muqing 1565 China CHN 1.0 self-made founder non-finance male 63.0 ... founder 1999.0 NaN auto distribution NaN NaN http://www.forbes.com/profile/wang-muqing/ http://www.zhengtongauto.com/en/milestone.html NaN NaN
2484 2014 Wang Yong 1565 China CHN 1.0 self-made founder non-finance male 63.0 ... founder 1986.0 NaN food sweeteners NaN NaN http://www.forbes.com/profile/wang-yong/ NaN NaN NaN
2494 2001 Wee Cho Yaw 490 Singapore SGP 1.0 inherited inherited male 72.0 ... relation 1935.0 8.928509e+10 NaN inherited from father NaN http://en.wikipedia.org/wiki/Wee_Cho_Yaw http://en.wikipedia.org/wiki/United_Overseas_Bank Wee Cho Yaw highest paid of local bank heads; ... NaN
2504 1996 Werhahn family 390 Germany DEU 1.0 inherited inherited NaN 0.0 ... NaN 1844.0 2.500000e+12 NaN NaN NaN http://de.wikipedia.org/wiki/Wilh._Werhahn_KG http://www.werhahn.de/en/home.html NaN NaN
2521 2001 William France Jr 490 United States USA 1.0 inherited inherited male 68.0 ... relation 1947.0 1.062180e+13 NaN inherited from father NaN http://en.wikipedia.org/wiki/Bill_France,_Jr. TOYOTA ENDURES HUMBLING DEBUT;TOP STORIES ALSO... NaN NaN
2524 2001 William Hearst III 490 United States USA 1.0 inherited inherited male 51.0 ... relation 1887.0 1.062180e+13 NaN 3rd generation NaN http://en.wikipedia.org/wiki/William_Randolph_... http://en.wikipedia.org/wiki/Hearst_Corporation SF UNZIPPED BLOG The San Francisco Chronicle (... NaN
2530 2014 William Moncrief, Jr. 1565 United States USA 1.0 inherited inherited male 93.0 ... relation 1929.0 NaN oil joined father's business following WWII NaN http://en.wikipedia.org/wiki/William_Moncrief http://www.moncriefoil.com/history.htm NaN NaN
2537 1996 Winthrop Rockefeller 416 United States USA 1.0 inherited inherited male 47.0 ... relation 1870.0 8.100200e+12 NaN 3rd generation NaN Agency celebrates 50th with Rockefeller tribut... NaN NaN NaN
2547 2014 Wu Chung-Yi 1565 Taiwan Taiwan 1.0 self-made executive male 55.0 ... investor 1991.0 NaN manufacturing NaN NaN http://www.forbes.com/profile/wu-chung-yi/ http://en.wikipedia.org/wiki/Tingyi_(Cayman_Is... Tingyi-Campbell sale talks stay on track South... NaN
2549 2014 Wu Xiong 1565 China CHN 1.0 self-made executive male NaN ... owner 1999.0 NaN infant formula NaN NaN http://www.forbes.com/profile/wu-xiong/ NaN NaN NaN
2561 2014 Yang Keng 1565 China CHN 1.0 self-made self-made finance male 53.0 ... chairman NaN NaN real estate NaN NaN http://www.forbes.com/profile/yang-keng/ NaN NaN NaN
2591 2014 Zdenek Bakala 1565 Czech Republic CZE 1.0 self-made privatized and resources male 53.0 ... founder 1994.0 NaN coal NaN NaN http://cs.wikipedia.org/wiki/Zden%C4%9Bk_Bakala NaN NaN NaN
2607 2014 Zhu Wenchen 1565 China CHN 1.0 self-made executive male 48.0 ... chairman 1999.0 NaN pharmaceuticals NaN NaN http://www.furenpharm.com/aboutus.asp?cid=82 http://www.forbes.com/profile/zhu-wenchen/ NaN NaN

171 rows × 30 columns


In [24]:
df['networthusbillion'].describe()


Out[24]:
count    2614.000000
mean        3.531943
std         5.088813
min         1.000000
25%         1.400000
50%         2.000000
75%         3.500000
max        76.000000
Name: networthusbillion, dtype: float64

In [25]:
df.groupby("gender")["networthusbillion"].describe()


Out[25]:
gender               
female          count     249.000000
                mean        3.819277
                std         5.046177
                min         1.000000
                25%         1.400000
                50%         2.100000
                75%         3.700000
                max        36.700000
male            count    2328.000000
                mean        3.516881
                std         5.123194
                min         1.000000
                25%         1.400000
                50%         2.000000
                75%         3.400000
                max        76.000000
married couple  count       3.000000
                mean        1.300000
                std         0.264575
                min         1.000000
                25%         1.200000
                50%         1.400000
                75%         1.450000
                max         1.500000
Name: networthusbillion, dtype: float64

In [28]:
#Adding the wealt of all the billionaires in a given country.
df.groupby('countrycode')['networthusbillion'].sum().sort_values(ascending=False)


Out[28]:
countrycode
USA       3542.1
DEU        671.0
RUS        434.9
CHN        377.1
HKG        338.2
FRA        336.9
JPN        280.3
BRA        224.7
ITA        220.3
IND        210.8
MEX        202.6
GBR        190.6
CAN        175.3
CHE        168.6
SWE        164.8
ESP        142.4
Taiwan     112.0
SAU        106.3
AUS         93.2
KOR         86.8
MYS         86.4
IDN         80.6
SGP         68.4
PHL         67.6
ISR         65.7
TUR         65.4
THA         60.3
CHL         52.7
NLD         38.5
COL         36.3
           ...  
ARE         16.5
KWT         15.5
PRT         13.6
FIN         13.3
PER         12.9
POL         12.8
NZL         10.8
KAZ          9.2
BEL          9.0
DNK          8.9
MAR          7.4
GEO          5.2
MCO          4.6
AGO          3.7
SWZ          3.7
DZA          3.2
LIE          2.9
MAC          2.8
GGY          2.4
OMN          2.3
BMU          2.1
VNM          1.6
KNA          1.2
ECU          1.2
ROU          1.2
NPL          1.1
UGA          1.1
BHR          1.0
LTU          1.0
TZA          1.0
Name: networthusbillion, dtype: float64

In [30]:
#What are the most common industries for billionaires to come from?
df['industry'].value_counts()


Out[30]:
Consumer                           471
Retail, Restaurant                 281
Real Estate                        280
Money Management                   249
Media                              219
Technology-Computer                208
Diversified financial              167
Energy                             132
Technology-Medical                 111
Non-consumer industrial            107
Constrution                         97
Mining and metals                   90
Other                               83
Hedge funds                         67
Private equity/leveraged buyout     25
0                                   16
Venture Capital                      8
banking                              1
services                             1
Name: industry, dtype: int64

In [32]:
df.groupby('industry')['networthusbillion'].sum()


Out[32]:
industry
0                                    24.7
Constrution                         236.4
Consumer                           1756.3
Diversified financial               702.9
Energy                              433.3
Hedge funds                         223.8
Media                               852.5
Mining and metals                   282.8
Money Management                    710.7
Non-consumer industrial             348.9
Other                               222.8
Private equity/leveraged buyout      87.9
Real Estate                         844.2
Retail, Restaurant                 1161.3
Technology-Computer                1015.2
Technology-Medical                  311.0
Venture Capital                      14.2
banking                               1.3
services                              1.2
Name: networthusbillion, dtype: float64

In [33]:
young_bills = df[df['age'] < 40]
young_bills.plot(kind='barh', x='name', y='networthusbillion').sort_values()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-33-246e6df5715b> in <module>()
      1 young_bills = df[df['age'] < 40]
----> 2 young_bills.plot(kind='barh', x='name', y='networthusbillion').sort_values()

AttributeError: 'AxesSubplot' object has no attribute 'sort_values'

In [ ]:
import pandas as pd
import matplotlib.pplot as plt
plt.style.use("ggplot")
%matplot