TeruakiUeda / faster_reduce_mem_usage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reduce_mem_usageを早くしたい

Comparison of the two methods

  • base code (overwrite)
if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
    df[col] = df[col].astype(np.int8)
  • change (concat)
dfs = []
...
if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:
    dfs.append(df[col].astype(np.int8))
...
df_out = pd.concat(dfs, axis=1)
  • result
    exp result

About


Languages

Language:Jupyter Notebook 94.5%Language:Python 5.5%