Skip to content

Pandas cheat sheet

Zakir Syed edited this page Jan 30, 2019 · 20 revisions

Data Frame - cleaning column names

df.columns = df.columns.str.replace(r'\s+', '_') #This replaces ' ' with '_' in col names

Data Frame - Efficiently iterating over all rows

for row in df.itertuples(): print(f"{row.Col_1} : {row.Col_2}")


Clone this wiki locally