import math
from matplotlib import pyplot
import random
def Interest_normal(principal):
rate=random.normalvariate(0.03,0.015)
return principal*rate
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()
pyplot.boxplot(end_balance)
pyplot.show()
import pandas as pd
import numpy as np
import seaborn as sns
employees = pd.read_excel('employee_data.xlsx')
employees.head()
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 |
table=pd.crosstab(employees.Education, employees.Gender)
table
Gender | 0 | 1 |
---|---|---|
Education | ||
0 | 2 | 8 |
2 | 9 | 10 |
4 | 46 | 69 |
6 | 24 | 27 |
8 | 4 | 5 |
table2 = pd.crosstab(employees.Gender,employees.Education)
table2
Education | 0 | 2 | 4 | 6 | 8 |
---|---|---|---|---|---|
Gender | |||||
0 | 2 | 9 | 46 | 24 | 4 |
1 | 8 | 10 | 69 | 27 | 5 |
sns.heatmap(table2)
<AxesSubplot:xlabel='Education', ylabel='Gender'>
sns.heatmap(table2,annot=True, linewidth=0.5,cmap='YlGnBu')
<AxesSubplot:xlabel='Education', ylabel='Gender'>
dict = {
'FirstName' : 'Jonathan',
"Last Name" : 'Freeman',
"LoginCount" : 4,
"isWriter" : True,
'WorksWith' : ['Spantree Technology Group', 'InfoWorld'],
'Pets' : [{
'name' : 'Lilly',
'type' : 'raccoon'
}]
}
dict
{'FirstName': 'Jonathan', 'Last Name': 'Freeman', 'LoginCount': 4, 'isWriter': True, 'WorksWith': ['Spantree Technology Group', 'InfoWorld'], 'Pets': [{'name': 'Lilly', 'type': 'raccoon'}]}
my_dict = {'Computer': 1500, "Monitor" : 300, "Printer" : 150, "Desk": 250}
my_dict
{'Computer': 1500, 'Monitor': 300, 'Printer': 150, 'Desk': 250}
df=pd.DataFrame(list(my_dict.items()),columns=['Products',"Prices"])
df
Products | Prices | |
---|---|---|
0 | Computer | 1500 |
1 | Monitor | 300 |
2 | Printer | 150 |
3 | Desk | 250 |