October 2019
Beginner to intermediate
674 pages
16h 43m
English
The following code block contains the equivalent of the earlier explained cut() function in pandas (only applies to version 0.15+):
In [79]: pd.set_option('precision',4)
clinical_trial=pd.DataFrame({'patient':range(1,1001),
'age' : np.random.normal(50,5,size=1000),
'year_enroll': [str(x) for x in np.random.choice(range(1980,2000),size=1000,replace=True)]})
In [80]: clinical_trial.describe()
Out[80]: age patient
count 1000.000 1000.000
mean 50.089 500.500
std 4.909 288.819
min 29.944 1.000
25% 46.572 250.750
50% 50.314 500.500
75% 53.320 750.250
max 63.458 1000.000
In [81]: clinical_trial.describe(include=['O'])
Out[81]: year_enroll
count 1000
unique 20
top 1992
freq 62
In [82]: clinical_trial.year_enroll.value_counts()[:6] ...Read now
Unlock full access