Skip to content

Instantly share code, notes, and snippets.

@jonathanoheix
Created December 18, 2018 09:48
Show Gist options
  • Save jonathanoheix/f8cd89300e567ef38da1130f07d8d4c7 to your computer and use it in GitHub Desktop.
Save jonathanoheix/f8cd89300e567ef38da1130f07d8d4c7 to your computer and use it in GitHub Desktop.
import pandas as pd
# read data
reviews_df = pd.read_csv("../input/Hotel_Reviews.csv")
# append the positive and negative text reviews
reviews_df["review"] = reviews_df["Negative_Review"] + reviews_df["Positive_Review"]
# create the label
reviews_df["is_bad_review"] = reviews_df["Reviewer_Score"].apply(lambda x: 1 if x < 5 else 0)
# select only relevant columns
reviews_df = reviews_df[["review", "is_bad_review"]]
reviews_df.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment