<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Data Visualization with Python
Authors
Step1:  Agenda
* </b>Pandas</b>
* <b>Pandas-Profiling</b>
* </b>Missingno</b>
* </b>Wordcloud</b>
Pandas-Profiling
https
Step2:  Load the admissions table (2/3)
Step3:  Profile the table (3/3)
Step4:  Agenda
* </b>Pandas</b>
* </b>Pandas-Profiling</b>
* <b>Missingno</b>
* </b>Wordcloud</b>
Missingno
https
Step5:  Agenda
* </b>Pandas</b>
* </b>Pandas-Profiling</b>
* </b>Missingno</b>
* <b>Wordcloud</b>
Wordcloud
https
Step6:  Prepare an input text in string (2/4)
Step7:  Generate a word-cloud from the input text (3/4)
Step8:  Plot the word-cloud (4/4)
<ASSISTANT_TASK:>
Python Code:
import pandas as pd
pd.set_option('display.max_columns', 999)
import pandas.io.sql as psql
# plot a figure directly on Notebook
import matplotlib.pyplot as plt
%matplotlib inline 
a = pd.read_csv("data/ADMISSIONS.csv")
a.columns = map(str.lower, a.columns)
a.groupby(['marital_status']).count()['row_id'].plot(kind='pie')
a.groupby(['religion']).count()['row_id'].plot(kind = 'barh') 
p = pd.read_csv("data/PATIENTS.csv")
p.columns = map(str.lower, p.columns)
ap = pd.merge(a, p, on = 'subject_id' , how = 'inner')
ap.groupby(['religion','gender']).size().unstack().plot(kind="barh", stacked=True)
c = pd.read_csv("data/CPTEVENTS.csv")
c.columns = map(str.lower, c.columns)
ac = pd.merge(a, c, on = 'hadm_id' , how = 'inner')
ac.groupby(['discharge_location','sectionheader']).size().unstack().plot(kind="barh", stacked=True)
Explanation: Data Visualization with Python
Authors: Prof. med. Thomas Ganslandt &#84;&#104;&#111;&#109;&#97;&#115;&#46;&#71;&#97;&#110;&#115;&#108;&#97;&#110;&#100;&#116;&#64;&#109;&#101;&#100;&#109;&#97;&#46;&#117;&#110;&#105;&#45;&#104;&#101;&#105;&#100;&#101;&#108;&#98;&#101;&#114;&#103;&#46;&#100;&#101; <br>
and Kim Hee &#72;&#101;&#101;&#69;&#117;&#110;&#46;&#75;&#105;&#109;&#64;&#109;&#101;&#100;&#109;&#97;&#46;&#117;&#110;&#105;&#45;&#104;&#101;&#105;&#100;&#101;&#108;&#98;&#101;&#114;&#103;&#46;&#100;&#101; <br>
Heinrich-Lanz-Center for Digital Health (HLZ) of the Medical Faculty Mannheim <br>
Heidelberg University
This is a part of a tutorial prepared for TMF summer school on 03.07.2019
Prerequisite: Access the MIMIC-III Dataset
The MIMIC (Medical Information Mart for Intensive Care) is a freely accessible database containing Intensive Care Unit (ICU) patients. The demo dataset is limited to 100 patients and publicly available as CSV files or as a single Postgres database backup file
Instruction to access the MIMIC demo dataset:
<font size="3">
1. Create an account on PhysioNet using the following link: https://physionet.org/register/
2. Navigate to the project page: https://physionet.org/content/mimiciii-demo/
3. Read the Data Use Agreement and click “I agree” to access the data
</font>
Prerequisite: MIMIC-III files locally
You should place the following MIMIC-III data files in the data/ subfolder:
ADMISSIONS.csv
PATIENTS.csv
CPTEVENTS.csv
<img src="images/er_mimic.png" style="width:100%">
Database description: https://mimic.physionet.org/gettingstarted/overview/
Table description: https://mimic.physionet.org/mimictables/admissions/
ER-Diagram: https://mit-lcp.github.io/mimic-schema-spy/relationships.html
Agenda
* <b>Pandas</b>
* </b>Pandas-Profiling</b>
* </b>Missingno</b>
* </b>Wordcloud</b>
Pandas
http://pandas.pydata.org/pandas-docs/stable/reference/ <br>
Pandas is a Python library for exploring, processing, and model data
Pandas supports charting a tabular dataset
DataFrame.plot([x, y], kind)
kind :
* 'line': line plot (default)
* 'bar': vertical bar plot
* 'barh': horizontal bar plot
* 'hist': histogram
* 'box': boxplot
* 'kde': Kernel Density Estimation plot
* 'density': same as 'kde'
* 'area': stacked area plot
* 'pie': pie plot
* 'scatter': scatter plot
* 'hexbin': Hexagonal binning plot 
<img src="images/DataVisualisation.jpeg" style="height: 1000px;"/>
Visualize the admission table
End of explanation
# !conda install -c conda-forge pandas-profiling -y
import pandas_profiling
Explanation: Agenda
* </b>Pandas</b>
* <b>Pandas-Profiling</b>
* </b>Missingno</b>
* </b>Wordcloud</b>
Pandas-Profiling
https://github.com/pandas-profiling/pandas-profiling <br>
Pandas-Profiling is a Python library for exploratory data analysis
Import pandas-profiling (1/3)
End of explanation
a = pd.read_csv("data/ADMISSIONS.csv")
a.columns = map(str.lower, a.columns)
Explanation: Load the admissions table (2/3)
End of explanation
# ignore the times when profiling since they are uninteresting
cols = [c for c in a.columns if not c.endswith('time')]
pandas_profiling.ProfileReport(a[cols])
Explanation: Profile the table (3/3)
End of explanation
# !conda install -c conda-forge missingno -y
import missingno as msno
msno.matrix(a)
Explanation: Agenda
* </b>Pandas</b>
* </b>Pandas-Profiling</b>
* <b>Missingno</b>
* </b>Wordcloud</b>
Missingno
https://github.com/ResidentMario/missingno <br>
Missingno offers a visual summary of the completeness of a dataset. This example brings some intuitive thoughts about ADMISSIONS table: 
* Not every patient is admitted to the emergency department as there are many missing values in edregtime and edouttime.
* language data of patients is mendatory field, but it used to be not.
End of explanation
# !conda install -c conda-forge wordcloud -y
from wordcloud import WordCloud
Explanation: Agenda
* </b>Pandas</b>
* </b>Pandas-Profiling</b>
* </b>Missingno</b>
* <b>Wordcloud</b>
Wordcloud
https://github.com/amueller/word_cloud <br>
Wordcloud visualizes a given text in a word-cloud format <br>
This example illustrates that majority of patients suffered from sepsis
Import the Wordcloud package (1/4)
End of explanation
text = str(a['diagnosis'].values)
Explanation: Prepare an input text in string (2/4)
End of explanation
wordcloud = WordCloud().generate(text)
Explanation: Generate a word-cloud from the input text (3/4)
End of explanation
import matplotlib.pyplot as plt
plt.figure(figsize = (10,10))
plt.imshow(wordcloud, interpolation = 'bilinear')
plt.axis("off")
plt.show()
Explanation: Plot the word-cloud (4/4)
End of explanation
<END_TASK>