Pandas Basics

Reading an excel sheet

Typical just use: import pandas as pd


Read specific sheet

pd.read_excel(“workbook_name.xlsx”, sheetname = “Sheet1)

Combining two data frames

df4 = pd.DataFrame({‘B’: [‘B2’, ‘B3’, ‘B6’, ‘B7’], …: ‘D’: [‘D2’, ‘D3’, ‘D6’, ‘D7’], …: ‘F’: [‘F2’, ‘F3’, ‘F6’, ‘F7’]}, …: index=[2, 3, 6, 7]) …:

In [9]: result = pd.concat([df1, df4], axis=1, sort=False) see []

Slicing a dataframe by row value in specific column

Readin in a json

import pandas as pd patients_df = pd.read_json(‘E:/datasets/patients.json’)

see [] or []

Read in a text file as a table

’’’ pd.read_csv(‘data/nodes.txt’,sep=”\t”,header=None) ‘’’

see []

Change entire series to a dictionary

use the map function []

Two series to dictionary



Mask dataframe if value is in list

use .isin() df[df[‘A’].isin([3, 6])] see