Importing the data into your Jupyter Notebook session

Notice that the extracted Hospital Compare folder includes 71 files, the vast majority of which are .csv files. That's a lot of tables! Let's import some of the tables into a Jupyter Notebook:

import pandas as pd

pathname = 'C:\Users\Vikas\Desktop\Bk\Data\Hospital_Revised_Flatfiles'

files_of_interest = [
'hvbp_tps_11_07_2017.csv',
'hvbp_clinical_care_11_07_2017.csv',
'hvbp_safety_11_07_2017.csv',
'hvbp_efficiency_11_07_2017.csv',
'hvbp_hcahps_11_07_2017.csv'
]

dfs = {
foi: pd.read_csv(pathname + foi, header=0) for foi in files_of_interest
}

The preceding code loads the tables pertaining to the HVBP measure into the Python session. There are five total tables, with four of the tables corresponding to the four domains of the measure, and one table representing the overall scores.

Note that instead of explicitly creating and importing five dataframes, we created a dictionary of dataframes using a comprehension. We covered dictionaries, lists, and comprehensions in the Python chapter. This saves a lot of typing in this cell and in upcoming cells.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset