Skip to content

Instantly share code, notes, and snippets.

@argenisleon
Last active August 22, 2018 19:49
Show Gist options
  • Select an option

  • Save argenisleon/0507cd781f3bb90e62292d378aa0af38 to your computer and use it in GitHub Desktop.

Select an option

Save argenisleon/0507cd781f3bb90e62292d378aa0af38 to your computer and use it in GitHub Desktop.
from optimus import Optimus
op = Optimus()
# This is a custom function
def func(value, arg):
return "this was a number"
df =op.load.url("https://raw.githubusercontent.com/ironmussa/Optimus/master/examples/foo.csv")
df\
.rows.sort("product","desc")\
.cols.lower(["firstName","lastName"])\
.cols.date_transform("birth", "new_date", "yyyy/MM/dd", "dd-MM-YYYY")\
.cols.years_between("birth", "years_between", "yyyy/MM/dd")\
.cols.remove_accents("lastName")\
.cols.remove_special_chars("lastName")\
.cols.replace("product","taaaccoo","taco")\
.cols.replace("product",["piza","pizzza"],"pizza")\
.rows.drop(df["id"]<7)\
.cols.drop("dummyCol")\
.cols.rename(str.lower)\
.cols.apply_by_dtypes("product",func,"string", data_type="integer")\
.cols.trim("*")\
.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment