Skip to content

Instantly share code, notes, and snippets.

@dzakyputra
Created June 16, 2020 23:59
Show Gist options
  • Save dzakyputra/10345c9c5d4cdc6bf6b0dbf135b6c161 to your computer and use it in GitHub Desktop.
Save dzakyputra/10345c9c5d4cdc6bf6b0dbf135b6c161 to your computer and use it in GitHub Desktop.
## Transcript preprocessing
# Convert the dictionary value into columns and concatenate with the current dataframe
value = pd.io.json.json_normalize(transcript['value'])
transcript = pd.concat([transcript, value], axis=1).drop(columns=['value'])
# Merge the offer_id column and offer id collumn so that it only has one column
transcript['offer_id'] = np.where(pd.isnull(transcript['offer_id']), transcript['offer id'], transcript['offer_id'])
transcript.drop(columns=['offer id'], inplace=True)
# Fill the null values with 0
transcript.fillna(0, inplace=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment