Cyclododecene / newsfeed

Newsfeed based on GDELT Project
GNU General Public License v3.0
21 stars 4 forks source link

Please can you help me? / geo_search #9

Closed jp-geoAI closed 2 years ago

jp-geoAI commented 2 years ago

I'm trying to create a dataframe with Pandas, with the results of a search of

geo_search

But I get this error:

ValueError: DataFrame constructor not properly called!

The code I am using: (https://github.com/Cyclododecene/newsfeed)

from newsfeed.news.apis.filters import *

from newsfeed.news.apis.query import *

f = Art_Filter(

keyword = ["Drugs", "Cocaine", "Police"],

start_date = "2022-01-01-00-00-00",

end_date = "2022-03-01-00-00-00",

country = ["Brazil", "BR"]

)

geo_7d = geo_search(query_filter = f, sourcelang="portuguese", timespan=7)

import pandas as pd

df=pd.DataFrame(geo_7d)

df.head()

Thanks!

TerenceLiu98 commented 2 years ago

Hi, @jp-geoAI

The output of geo_7d = geo_search(query_filter = f, sourcelang="portuguese", timespan=7) is str thus, you may not load the string into the pd.DataFrame. We are trying to reconstruct this function, as we have mentioned in Issue #8.

The temporary solution is loading it with json

import json
import pandas as pd
geo_7d_json = json.loads(geo_7d)
pd.DataFrame(geo_7d_json)
jp-geoAI commented 2 years ago

thank you very much! @TerenceLiu98

TerenceLiu98 commented 2 years ago

ur welcome :)