data.head(10)

"""
Explanation: Read the first 10 rows.
End of explanation
"""


data.tail(10)

"""
Explanation: Read the last 10 rows.
End of explanation
"""


data.shape

"""
Explanation: Show the number of elements.
End of explanation
"""


data.columns

"""
Explanation: Show the column names.
End of explanation
"""


data.set_index('id').head(5)

"""
Explanation: Make  id  column  the  index.
End of explanation
"""


data.dtypes

"""
Explanation: Show  the  data  types  of  each  column.
End of explanation
"""


data['(xi-x)^2'] = (data['mass'] - data['mass'].mean())**2
data.head()

SD = math.sqrt(sum(data['(xi-x)^2'])/data.shape[0])
M = data['mass'].mean()
print('SD = ',SD,', mean = ',M)

"""
Explanation: Start  to  manage  data.
Now I try to calculate the standard diviation of the mass.
End of explanation
"""


data['mass_group'] = pd.cut(data['mass'],bins=[min(data['mass']),M-3*SD,M-2*SD,M-SD,M+SD,M+2*SD,M+3*SD,max(data['mass'])],labels=["<(-3SD)","-3SD~-2SD","-2SD~-SD","-SD~+SD","+SD~+2SD","+2SD~+3SD",">(+3SD)"])

data

pd.value_counts(data['mass_group'])

"""
Explanation: Group the data by the standard diviation of the mass.
End of explanation
"""


1603364/data.shape[0]

(1603364+323872+290594)/data.shape[0]

(1603364+323872+290594+66373+34290)/data.shape[0]

"""
Explanation: Now I calculate how many data are wihtin 1 standard diviation, 2 standard diviatioa, and 3 standard diviation respectively.
End of explanation
"""


data.groupby(['mass_group'])['voc'].describe()

"""
Explanation: <span style="color:red">Though I didn't know what these data are, I found the mass of these chemicals are nearly normal distribution!
End of explanation
"""


data.groupby(['mass_group'])['voc'].mean().plot()

"""
Explanation: Get a plot voc v.s. grouped data
End of explanation
"""


data.groupby(['mass_group'])['tmp_smiles_str'].count().plot().hist(20)

"""
Explanation: Get another plot.
End of explanation
"""


