Skip to content

Instantly share code, notes, and snippets.

View frank-yifei-wang's full-sized avatar

Frank Wang frank-yifei-wang

View GitHub Profile
@RichardBronosky
RichardBronosky / pep8_cheatsheet.py
Created December 27, 2015 06:25
PEP-8 cheatsheet
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""This module's docstring summary line.
This is a multi-line docstring. Paragraphs are separated with blank lines.
Lines conform to 79-column limit.
Module and packages names should be short, lower_case_with_underscores.
Notice that this in not PEP8-cheatsheet.py
@sainathadapa
sainathadapa / anti_join.py
Created May 9, 2018 10:00
anti-join-pandas
import pandas as pd
def anti_join(x, y, on):
"""Return rows in x which are not present in y"""
ans = pd.merge(left=x, right=y, how='left', indicator=True, on=on)
ans = ans.loc[ans._merge == 'left_only', :].drop(columns='_merge')
return ans
def anti_join_all_cols(x, y):
@frank-yifei-wang
frank-yifei-wang / view.py
Created August 29, 2019 16:55
View Pandas DataFrame in a pop-up window/tab rendered with JavaScript and CSS code. Similar to RStudio's 'View' function.
from IPython.display import HTML
def view(df=None, title: str = 'DataFrame', fs: int = 12):
"""View Pandas DataFrame in a pop-up window/tab rendered with JavaScript and CSS code. Similar to RStudio's 'View' function.
Args:
df: DataFrame to view
title: title of the pop-up (to help distinguish if there are multiple pop-ups)
fs: font size in pixels
Examples: