0

Is there a way to use IP2Location database.get_all() and convert the results into a Pandas DataFrame? I am really lost and confused as to how to do it.

I have gotten an error AttributeError: 'IP2LocationRecord' object has no attribute 'values'.

The values I obtained

{'ip': '104.145.231.146', 'country_short': 'US', 'country_long': 'United States of America', 'region': 'New York',
 'city': 'Buffalo', 'latitude': 42.886452, 'longitude': -78.878372, 'zipcode': '14201', 'timezone': '-05:00'}

Expected outcome

     ip                 country_short    country_long        ....       zipcode      timezone
0    104.145.231.146    US               United States of America       14201        -05:00
  • try `pd.DataFrame.from_dict(database.get_all(),orient='index').T` – anky Jan 31 '21 at 03:24
  • I've gotten a TypeError. ```TypeError: object of type 'IP2LocationRecord' has no len()``` – noobprogrammerzzz Jan 31 '21 at 03:32
  • we dont know what `IP2LocationRecord` is so cannot say whats the issue. Your question should be edited to include all details. or atleast to an extent which is reproducible, the above code worked for ṭhe values you obtained, assuming the type is a dictionary – anky Jan 31 '21 at 03:37

0 Answers0