# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import requests
import json
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# import GetOldTweets3 as got
# import random
import pickle
import seaborn as sns
import sys

# #### Reading of CSV

df = pd.read_csv('combined_df.csv')

df.drop(["Unnamed: 0"], axis=1, inplace=True)

df.set_index("user_id", inplace=True)

df.iloc[0].values.reshape(1,-1).shape

df

# #### Step 1: Imagine if we have a user's data (i.e one row of the csv) in a list.

test = df.iloc[0].values.tolist()

test

# #### Step 2: We can now make use the API.

endpoint_url = 'https://dt4o8agm5c.execute-api.us-east-1.amazonaws.com/v1'

# #### Step 5: Make either a single row request or multiple users row request:

# +
request = {
  "instances": [
    {
      "features": [test] # from [10]
    }
  ]
}
# Note that each row is something like {"features":[[val1, val2]]}

multiple_request = {
  "instances": [
    {
      "features": [test]
    },
    {
  "features": [test]
    }
    ,
    {
  "features": [test]
    }
  ]
}


# -

response = requests.post(endpoint_url, data=json.dumps(request))

result

# #### Multiple data example:

response2 = requests.post(endpoint_url, data=json.dumps(multiple_request))

result2 = response2.json()

result2

StarcoderdataJupyterScriptsDedupFiltered