admin管理员组文章数量:1332889
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...
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...
Share
Improve this question
edited Nov 21, 2024 at 2:51
Julien
15.2k6 gold badges33 silver badges58 bronze badges
asked Nov 21, 2024 at 2:46
Alex SchiffAlex Schiff
131 bronze badge
2
- Is that a string? Then just read a tutorial on string manipulation... otherwise we need more clarity. How to Ask and minimal reproducible example – Julien Commented Nov 21, 2024 at 2:53
- @Julien It turns out its another object called APIResponse – Anubhav Sharma Commented Nov 21, 2024 at 3:14
1 Answer
Reset to default 1Use 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
本文标签: pythonHow do I remove the quotdataquot from an API responseStack Overflow
版权声明:本文标题:python - How do I remove the "data=" from an API response? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742317105a2452037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论