Python_01e

This page covers are the absolute basics of line plotting using Dataframes

Simple dataframe

First import the libraries to do the plots and conversions

(Which libraries you choose to use comes with experience)

import pandas as pd

import seaborn as sns

Then create some dummy data 

#dummy example data in the form of a 'dictionary'

table1 = {'names': ['Jack', 'Clara','Alex', \

                    'Julia', 'Steve', 'Suki',\

                    'Yoko', 'Julie', 'Stephan',\

                    'James', 'Carl','Amy', \

                    'Judith', 'Sam', 'Amita',\

                    'Aoi', 'Julia', 'Stephan'],

          'gender': ['M','F','F','F','M','F','F','F','M',\

                     'M','F','M','F','M','F','F','F','M'],

          'weight':[76, 51, 55, 59, 90, 57, 49, 58, 92,\

                    73, 54, 51, 61, 89, 58, 50, 55, 87],

          'height': [173, 168, 165, 171, 167, 158, 138, 178, 173, \

                     164, 173, 155, 168, 171, 151, 139, 172, 169]}


Change the dummy data to a DataFrame to suit the Seaborn plot 

Make a plot 

Save the data for later to a generic csv file

patients = pd.DataFrame(table1)


sns.pairplot(patients, hue='gender')


patients.to_csv('patients_info.csv')