# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.8.8 64-bit (''base'': conda)'
#     name: python3
# ---

import pandas as pd
import os

book = pd.read_csv("sales2019.csv")
df = pd.DataFrame(book)
df

# +

df.user_submitted_review.unique()
df.title.unique()


# +
usercount = [0,0,0]
x = "Individual"
# negative, neutral, positive 



print(usercount)

# -

def query(title, customer_type):
    usercount = [0,0,0]
    for i in range(len(df)):
        if df.loc[i, "title"] == title:
            if customer_type == "all":
                if df.loc[i, "user_submitted_review"] == "it was okay":
                    usercount[2] = usercount[2] + 1
                elif df.loc[i, "user_submitted_review"] == "Awesome!":
                    usercount[2] = usercount[2] + 1
                elif df.loc[i, "user_submitted_review"] == "I learned a lot":
                    usercount[2] = usercount[2] + 1
                elif df.loc[i, "user_submitted_review"] == "Never read a better book":
                    usercount[2] = usercount[2] + 1
                elif df.loc[i, "user_submitted_review"] == "OK":
                    usercount[1] = usercount[1] + 1
                elif df.loc[i, "user_submitted_review"] == "A lot of material was not needed":
                    usercount[1] = usercount[1] + 1
                elif df.loc[i, "user_submitted_review"] == "The author''s other books were better":
                    usercount[1] = usercount[1] + 1
                elif df.loc[i, "user_submitted_review"] == "Would not recommend":
                    usercount[0] = usercount[0] + 1
                elif df.loc[i, "user_submitted_review"] == "Hated it":
                    usercount[0] = usercount[0] + 1
            if df.loc[i, "user_submitted_review"] == "it was okay" and df.loc[i, "customer_type"] == customer_type:
                usercount[2] = usercount[2] + 1
            elif df.loc[i, "user_submitted_review"] == "Awesome!" and df.loc[i, "customer_type"] == customer_type:
                usercount[2] = usercount[2] + 1
            elif df.loc[i, "user_submitted_review"] == "I learned a lot" and df.loc[i, "customer_type"] == customer_type:
                usercount[2] = usercount[2] + 1
            elif df.loc[i, "user_submitted_review"] == "Never read a better book" and df.loc[i, "customer_type"] == customer_type:
                usercount[2] = usercount[2] + 1
            elif df.loc[i, "user_submitted_review"] == "OK" and df.loc[i, "customer_type"] == customer_type:
                usercount[1] = usercount[1] + 1
            elif df.loc[i, "user_submitted_review"] == "A lot of material was not needed" and df.loc[i, "customer_type"] == customer_type:
                usercount[1] = usercount[1] + 1
            elif df.loc[i, "user_submitted_review"] == "The author''s other books were better" and df.loc[i, "customer_type"] == customer_type:
                usercount[1] = usercount[1] + 1
            elif df.loc[i, "user_submitted_review"] == "Would not recommend" and df.loc[i, "customer_type"] == customer_type:
                usercount[0] = usercount[0] + 1
            elif df.loc[i, "user_submitted_review"] == "Hated it" and df.loc[i, "customer_type"] == customer_type:
                usercount[0] = usercount[0] + 1
    print(usercount)


query("Top 10 Mistakes R Beginners Make", "all")

# +
monthdate = []
for i in range(len(df)):
    monthdate.append(df.loc[i, "date"].replace("/", ""))

len(monthdate)

# +
for x in range(len(monthdate)):
    if int(monthdate[x][:2]) > 12:
        monthdate[x] = monthdate[x][:1]
    else:
        monthdate[x] = monthdate[x][:2]

monthdate
# -



StarcoderdataJupyterScriptsDedupFiltered