🐼

Pandas Reference

import pandas as pd
from sqlalchemy import create_engine

Pandas Data Structures

pd.DataFrame()
pd.Series()

I/O

df = pd.read_csv('csv.csv') 
df.to_csv('new_csv.csv')

df = pd.read_excel('csv.xlsx', sheet_name='sheet') 
df.to_csv('new_csv.xlsx')

df.to_pickle('cucumber.pkl')

df = pd.from_dict(dict())
data = df.to_dict()
data = df.to_json()
data = df.to_html()


engine = create_engine(' sqlite://local/')
pd.read_sql("SELECT * FROM table;", engine)
pd.read_sql_table('table’, engine)
pd.read_sql_query("SELECT * FROM table;", engine)

df.to_sql('df', engine)

DataFrame Manipulation

df.drop(['col1'])
df.drop(['col1'], axis = 1) 
df_col1_col2 = df[['col1','col2'])

df.set_index()
df.sort_index()
df.sort_values(by='col1')
df.shift(-1)

df.rank()
df.mean()/median()/mode()/std()

df.apply(lambda x: x)
df.applymap(lambda x: x)

df.merge()
df.transpose()