merj / bing-webmaster-tools

Python wrapper for the Bing Webmaster Tools API
MIT License
15 stars 0 forks source link

Add DataFrame support #1

Open antoineeripret opened 1 week ago

antoineeripret commented 1 week ago

Hi everyone,

I've been playing with your library (mainly with Traffic Analysis methods), amazing work !

I have a couple of suggestions.

DataFrame

Instead of keeping the raw format (confusing) returned by the API, I'd transform it into a Pandas DataFrame to ease the analysis. This can be done through this generic function that we could adapt for your library:

def get_response(request_url, params):
    request = requests.get(request_url, params=params)
    query_data = json.loads(request.text)
    df = pd.DataFrame(query_data['d'])
    return df

And instead of returning a datetime.datetime object, I'd use a regular "YYYY-MM-DD" for the date.

Let me know what you think :)

Have a lovely weekend,

Antoine.

eliasdabbas commented 6 days ago

Fully agree @antoineeripret as this is going to make analysis immediate.

You can easily create a DataFrame right now though you have to loop through the available keys(columns):

https://github.com/merj/bing-webmaster-tools/issues/3

The simpler approach is probably just running pd.DataFrame on the response.json() object as you show.