Skip to content

Instantly share code, notes, and snippets.

View Brainor's full-sized avatar

Brainor Brainor

  • Peking University
  • Beijing
  • 18:35 (UTC +08:00)
View GitHub Profile
@Brainor
Brainor / python_benchmark.py
Last active April 25, 2021 03:53 — forked from Coldsp33d/conditional_col_creation_benchmark.py
比较代码所需时间
import pandas as pd
import perfplot
def numpy_where(df):
return df.assign(is_rich=np.where(df['salary'] >= 50, 'yes', 'no'))
def list_comp(df):
return df.assign(is_rich=['yes' if x >= 50 else 'no' for x in df['salary']])
def loc(df):