Skip to content
Snippets Groups Projects
Commit 1d3ae221 authored by tkadambi's avatar tkadambi
Browse files

workshop 3 correct version

parent 1f3b0e14
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
```
%% Cell type:code id: tags:
``` python
df = pd.read_csv('HospitalAdmissionsData.csv')
```
%% Cell type:code id: tags:
``` python
df.columns
```
%% Output
Index(['ID', 'AdmissionLengthDays', 'Death_1', 'Admission_Type',
'Insurance_Type', 'EnglishLanguage_1', 'Religion_Type', 'Married_1',
'Race', 'Dx'],
dtype='object')
%% Cell type:code id: tags:
``` python
df.dtypes.value_counts()
```
%% Output
object 5
int64 4
float64 1
dtype: int64
%% Cell type:code id: tags:
``` python
df["Insurance_Type"].unique()
```
%% Output
array(['private', 'medicare', 'government', 'medicaid', 'self pay'],
dtype=object)
%% Cell type:code id: tags:
``` python
df.describe()
```
%% Output
ID AdmissionLengthDays Death_1 EnglishLanguage_1 \
count 58863.000000 58863.000000 58863.000000 58863.000000
mean 29508.211984 10.138978 0.099417 0.571072
std 17026.189024 12.465611 0.299224 0.494927
min 1.000000 -0.945139 0.000000 0.000000
25% 14762.500000 3.743056 0.000000 0.000000
50% 29523.000000 6.465972 0.000000 1.000000
75% 44254.500000 11.798264 0.000000 1.000000
max 58976.000000 294.660417 1.000000 1.000000
Married_1
count 58863.000000
mean 0.410665
std 0.491959
min 0.000000
25% 0.000000
50% 0.000000
75% 1.000000
max 1.000000
%% Cell type:code id: tags:
``` python
print(df["Admission_Type"].mode())
print(df["Insurance_Type"].mode())
print(df["Religion_Type"].mode())
print(df["Race"].mode())
print(df["Dx"].mode())
```
%% Output
0 emergency
dtype: object
0 medicare
dtype: object
0 catholic
dtype: object
0 white
dtype: object
0 newborn
dtype: object
%% Cell type:code id: tags:
``` python
fig, ax = plt.subplots()
df["AdmissionLengthDays"].hist(ax=ax, bins=100, bottom=0.1)
ax.set_yscale('log')
```
%% Output
%% Cell type:code id: tags:
``` python
# Our data...
x = np.linspace(0, 10, 100)
y1, y2, y3 = np.cos(x), np.cos(x + 1), np.cos(x + 2)
names = ['Signal 1', 'Signal 2', 'Signal 3']
fig = plt.figure(figsize = (9,9))
sig1 = fig.add_subplot(311)
sig1.plot(x, y1)
sig1.title.set_text(names[0])
sig1.axes.xaxis.set_visible(False)
sig1.axes.yaxis.set_visible(False)
sig2 = fig.add_subplot(312)
sig2.plot(x, y2)
sig2.title.set_text(names[1])
sig2.axes.xaxis.set_visible(False)
sig2.axes.yaxis.set_visible(False)
sig3 = fig.add_subplot(313)
sig3.plot(x, y3)
sig3.title.set_text(names[2])
sig3.axes.xaxis.set_visible(False)
sig3.axes.yaxis.set_visible(False)
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
```
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment