bp : Module Bhishan

In a life of a data scientist, we tend to use some pieces of code again and again. Instead of writing same functions again and again, it is a better idea to write our own module and use the specific functions best suited to our own purpose.

Tutorials

I have included one basic tutorial notebook for the demonstration.

API Documentation

The module bp has some classes and various utility functions. bp is the main class and utils is one the utilities.

Script ds_json

Utility function for json.

class ds_json.MyJson[source]
parse_json_col(df, json_col)[source]

Explode the json column and attach to original dataframe.

Parameters:
  • df (pandas.DataFrame) – input dataframe
  • json_col (string) – Column name of dataframe which contains json objects.
  • Example
  • --------
  • numpy as np (import) –
  • pandas as pd (import) –
  • pd.options.display.max_colwidth=999
  • bp.ds_json import MyJson (from) –
  • = pd.DataFrame({'id' (df) –
    ‘payload’: [“””{“analytics”: {“device”: “Desktop”,
    ”email_open_rate_pct”: 14.0},

    ”industry”: “Construction”, “time_in_product_mins”: 62.45}”””]

    })

  • = MyJson() (mj) –
  • = mj.parse_json_col(df,'payload') (ans) –