Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import dask.dataframe as dd
  2. import pandas as pd
  3. import numpy as np
  4. df = pd.DataFrame({"a": np.arange(100)})
  5. ddf = dd.from_pandas(df, npartitions=4)
  6.  
  7. # silly function. it just append the mean for every columns to every partition
  8. def fun(x):
  9.     x = pd.concat([x, x.mean().to_frame().T], ignore_index=True)
  10.     return x
  11.  
  12. out = ddf.map_partitions(lambda x: fun(x)).compute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement