0

I am scraping data from GDELT [https://www.gdeltproject.org]. It is a pretty cool project that checks ~100,000 news sites each day, labels all the articles, and makes them available. I am getting attribute error while extracting the data. The code use is the following:

import gdelt
gd = gdelt.gdelt(version=1)
from statsmodels.tsa.api import VAR
import pandas as pd
import os
os.makedirs("data",exist_ok=True)
import datetime

cur_date = datetime.datetime(2022,1,10) - datetime.timedelta(days=10)
end_date = datetime.datetime(2022,1,10)

year     = cur_date.year
month    = str(cur_date.month)
day      = str(cur_date.day)

if cur_date.month < 10:
    month = "0" + month
if cur_date.day < 10:
    day = "0" + day  

gd.Search(['%s %s %s'%(year, month, day)],table='gkg',coverage=True, translation=False)

I am getting attribute error

 AttributeError                            Traceback (most recent call last)
 <ipython-input-10-2f00cabbf1ac> in <module>
 ----> 1 results = gd.Search(['%s %s %s'%(year, month, day)],table='gkg',coverage=True, 
 translation=False)

 ~\anaconda3\lib\site-packages\gdelt\base.py in Search(self, date, table, coverage, 
 translation, output, queryTime, normcols)
 646 
 647         if self.table == 'gkg' and self.version == 1:
 --> 648             results.columns = results.ix[0].values.tolist()
 649             results.drop([0], inplace=True)
 650             columns = results.columns

 ~\anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
 5463             if self._info_axis._can_hold_identifiers_and_holds_name(name):
 5464                 return self[name]
 -> 5465             return object.__getattribute__(self, name)
 5466 
 5467     def __setattr__(self, name: str, value) -> None:

 AttributeError: 'DataFrame' object has no attribute 'ix'
shan
  • 553
  • 2
  • 9
  • 25
  • gdelt expects an older version of pandas but you have a too-new version for it. `.ix` has been removed from pandas. –  Jan 10 '22 at 11:16
  • @Neither how to resolve this error, if I have higher version of Pandas – shan Jan 10 '22 at 14:31
  • you can either downgrade pandas for gdelt, or upgrade gdelt –  Jan 10 '22 at 15:23
  • AFAIK, `.ix` was last seen on pandas 0.23.1; so `pip install pandas==0.23.1`. But note that this *may* cause some other dependency issues with other libraries. –  Jan 10 '22 at 15:26

0 Answers0