SOSamuel Oranyeliindatawrangler.hashnode.dev·Jan 18, 2021 · 4 min readData Wrangling with Python Datatable - Conditional StatementsTransformation based on a Single Condition Source data Task: if c is positive, then value should be a - b, else b - a. from datatable import dt, f, update, ifelse df = dt.Frame({"a": [1, 1, 2, 4], "b": [2, 2, 3, 2], "...00
SOSamuel Oranyeliindatawrangler.hashnode.dev·Jan 8, 2021 · 3 min readData Wrangling with Python Datatable - Row-wise TransformationsLink to Source data datatable docs Task: Get the difference between the maximum and minimum values per row for Value columns. from datatable import dt, f, update df = dt.Frame({'Ind': [1, 2, 3], 'Department': ['Electronics', 'Clothing...00
SOSamuel Oranyeliindatawrangler.hashnode.dev·Jan 7, 2021 · 2 min readData Wrangling with Python Datatable - Transformations Within a GroupByLink to Source data Task: Group data by Date and Zip and get the ratio of Price to maximum Price per group. from datatable import dt, f, update, by df = dt.Frame( { "Date": ["2019-01-01", "2019-01-01", "2019-01-01", "20...00
SOSamuel Oranyeliindatawrangler.hashnode.dev·Jan 6, 2021 · 2 min readData Wrangling with Python Datatable - Select Columns by Data TypeLink to Source data Datatable docs ltype stypes from datatable import dt, f df = dt.Frame({'a': [1, 2, 1, 2, 1, 2], 'b': [True, False, True, False, True, False], 'c': [1.0, 2.0, 1.0, 2.0, 1.0, 2.0]}) df | a ...00
SOSamuel Oranyeliindatawrangler.hashnode.dev·Jan 4, 2021 · 3 min readData Wrangling with Python Datatable - Replicate Pandas' Map FunctionLink to Source data Task: Create a new column by mapping the values in the city column to the city_state dictionary from datatable import dt, f raw_data = {"first_name": ["Jason", "Molly", "Tina", "Jake", "Amy"], ...00