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)
In [10]:
print(df.columns.values)
In [13]:
print(df['animal'])
In [19]:
print(df[:3])
In [27]:
print(df)
In [32]:
print(df.sort_values(by='length', ascending=0)[:3])
In [45]:
print(df['animal'])
In [66]:
print(df['animal'].value_counts())
In [77]:
dogs = df[df['animal'] == 'dog']
dogs
Out[77]:
In [78]:
df[df['length'] > 40]
Out[78]:
In [81]:
df['inches'] = df['length'] * .394
df
Out[81]:
In [90]:
cats = df[df['animal'] == 'cat']
cats
Out[90]:
In [91]:
dogs = df[df['animal'] == 'dog']
dogs
Out[91]:
In [92]:
cats[cats['inches'] > 12]
Out[92]:
In [99]:
df[df['inches'] > 12]
df[df['animal'] == 'cat']
Out[99]:
In [103]:
cats['length'].mean()
Out[103]:
In [104]:
dogs['length'].mean()
Out[104]:
In [105]:
df.groupby('animal')['length'].mean()
Out[105]:
In [110]:
dogs['length'].hist()
Out[110]:
In [111]:
dogs.plot(kind='scatter', x='length', y='inches')
Out[111]:
In [113]:
df.plot(kind='barh', x='name', y='length', legend=False)
Out[113]:
In [119]:
sortcats = (cats.sort_values(by='length', ascending=0))
sortcats.plot(kind='barh', x='name', y='length', legend=False, sort_columns=False)
Out[119]:
In [117]:
cats
Out[117]:
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
In [6]:
%matplotlib inline
In [7]:
print(df['gender'].value_counts())
In [8]:
df.groupby('gender')['networthusbillion'].mean()
Out[8]:
In [10]:
df.groupby('gender')['sourceofwealth'].value_counts()
Out[10]:
In [12]:
df.plot(kind='scatter', x='gender', y='networthusbillion')
In [ ]: