In [1]:
import math
from matplotlib import pyplot
import random
In [2]:
def Interest_normal(principal):
    rate=random.normalvariate(0.03,0.015)
    return principal*rate
In [3]:
years=10
sims=10000
end_balance=[]
for i in range(sims):
    time=0
    balance=1200
    while(time<years):
        balance+=Interest_normal(balance)
        time+=1
    end_balance.append(balance)
    
pyplot.hist(end_balance, bins=20)
pyplot.show()
In [4]:
pyplot.boxplot(end_balance)
pyplot.show()
In [5]:
import pandas as pd
import numpy as np
import seaborn as sns
In [6]:
employees = pd.read_excel('employee_data.xlsx')
employees.head()
Out[6]:
Employee Gender Age Prior Experience Beta Experience Education Annual Salary
0 1 1 39 5 12 4 57700
1 2 0 44 12 8 6 76400
2 3 0 24 0 2 4 44000
3 4 1 25 2 1 4 41600
4 5 0 56 5 25 8 163900
In [7]:
table=pd.crosstab(employees.Education, employees.Gender)
table
Out[7]:
Gender 0 1
Education
0 2 8
2 9 10
4 46 69
6 24 27
8 4 5
In [8]:
table2 = pd.crosstab(employees.Gender,employees.Education)
table2
Out[8]:
Education 0 2 4 6 8
Gender
0 2 9 46 24 4
1 8 10 69 27 5
In [9]:
sns.heatmap(table2)
Out[9]:
<AxesSubplot:xlabel='Education', ylabel='Gender'>
In [10]:
sns.heatmap(table2,annot=True, linewidth=0.5,cmap='YlGnBu')
Out[10]:
<AxesSubplot:xlabel='Education', ylabel='Gender'>
In [11]:
dict = {
    'FirstName' : 'Jonathan',
    "Last Name" : 'Freeman',
    "LoginCount" : 4,
    "isWriter" : True,
    'WorksWith' : ['Spantree Technology Group', 'InfoWorld'],
    'Pets' : [{
        'name' : 'Lilly',
        'type' : 'raccoon'
    }]
}

dict
Out[11]:
{'FirstName': 'Jonathan',
 'Last Name': 'Freeman',
 'LoginCount': 4,
 'isWriter': True,
 'WorksWith': ['Spantree Technology Group', 'InfoWorld'],
 'Pets': [{'name': 'Lilly', 'type': 'raccoon'}]}
In [12]:
my_dict = {'Computer': 1500, "Monitor" : 300, "Printer" : 150, "Desk": 250}
my_dict
Out[12]:
{'Computer': 1500, 'Monitor': 300, 'Printer': 150, 'Desk': 250}
In [13]:
df=pd.DataFrame(list(my_dict.items()),columns=['Products',"Prices"])
df
Out[13]:
Products Prices
0 Computer 1500
1 Monitor 300
2 Printer 150
3 Desk 250
In [ ]: