%matplotlib inline
!pip install seaborn
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
df = pd.read_csv('fortune500.csv')
import pandas as pd
df.head()
df.tail()
df.tail()
df.columns = ['year', 'rank', 'company', 'revenue', 'profit']
len(df)
df.dtypes
non_numeric_profit = df.profit.str.contains('[^0-9.-]')
df.loc[non_numeric_profit].head()
set(df.profit[non_numeric_profit])
len(df.profit[non_numeric_profit])
df = df.loc[~non_numeric_profit]
df.profit = df.profit.apply(pd.to_numeric)
len(df)
df.dtypes
group_by_year = df.loc[:,['year','revenue','profit']].groupby('year')
avgs = group_by_year.mean()
x = avgs.index
y1 = avgs.profit
def plot(x,y,ax,title,y_label):
ax.set_title(title)
ax.set_ylabel(y_label)
ax.plot(x,y)
ax.margins(x=0, y=0)
fig,ax=plt.subplots()
plot(x, y1, ax, 'Increase in mean Fortune 500 company profits', 'Profit(million)')
y2 = avgs.revenue
fig, ax = plt.subplots()
plot(x, y2, ax, 'Increase in mean revenue', 'Revenue(millions)')
avgs
avgs
non_numeric_profit
non_numeric_profit
non_numeric_profit
y1
y1
group_by_year
group_by_year
non_numeric_profit
input = '123'
print(input)