0

I'm very new to python and pandas and I'm working a project for a distance matrix. I got an API that gets distance data from two points and I 'd like to export to excel or csv.

I'm getting a module "pandas" has no attribute "Dataframe"

import requests
import json
import pandas as pd



origin="Centro Hospitalar Universitário de São João, E. P. E"
destination="Braga"
api="api"

response=requests.get("https://api.distancematrix.ai/maps/api/distancematrix/json?        origins="+origin+"&destinations="+destination+"&key="+api+"")

print(response.status_code)
print(response.json())


df=pd.Dataframe.from_dict(response.json())
df.to_excel("filepath")

I tried capitalizing Dataframe and made sure that I don't have any pd variable or pandas.py file name

0

1 Answer 1

1

It is DataFrame, python is case-sensitive, so use it like this:

df = pd.DataFrame.from_dict(response.json())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.