pythonpandassupabase

How do I remove the "data=" from an API response?


I'm pretty new to this, especially working with APIs. I am working with an API response from a postgres database. When I get the data back, it has a "data=" attached to the front like this:

data=[{'faculty_id': 2, 'first_name': 'Erin',....

I'm trying to place the data into a pandas dataframe, but having that extra bit at the front isn't helping. Any way I can strip off that first bit?

Current code:

response = supabase.table("faculty").select("*").execute()
# print(response)
df1 = pd.DataFrame(response)
df1

What I'm getting back:

    0   1
0   data    [{'faculty_id': 2, 'first_name': 'Erin', 'last...
1   count   None
2   __orig_class__  postgrest.base_request_builder.APIResponse[~_R...

Solution

  • Use like this:

    response = supabase.table("faculty").select("*").execute()
    df1 = pd.DataFrame(response[5:])
    df1
    

    or

    response = supabase.table("faculty").select("*").execute()
    df1 = pd.DataFrame(response.data)
    df1