InseeFrLab / pynsee

pynsee package contains tools to easily search and download french data from INSEE and IGN APIs
https://pynsee.readthedocs.io/en/latest/
MIT License
69 stars 10 forks source link

Error with get_location on Sirene #131

Closed raphadasilva closed 1 year ago

raphadasilva commented 1 year ago

I'm just following this simple example provided in this repo. My first data is:

test = search_sirene(variable = ["activitePrincipaleEtablissement", "codeCommuneEtablissement"],
                         pattern = ["13.20Z", "68*"], kind = 'siret', number=1000)

But when I execute this to get the associated locations:

test = test.get_location()

Got this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5040/2220752205.py in <module>
----> 1 test = test.get_location()

~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5485         ):
   5486             return self[name]
-> 5487         return object.__getattribute__(self, name)
   5488 
   5489     def __setattr__(self, name: str, value) -> None:

AttributeError: 'DataFrame' object has no attribute 'get_location'

I noticed that the get_location method could have been renamed _get_location_openstreetmap, but it didn't solve this issue.

What can I do ?

hadrilec commented 1 year ago

hello,

the example below is working on my side on Linux and Python 3.10. Kind reminder, you should use get_location straight after having used search_sirene. This method can only be used on SireneDataFrame objects and not on pandas DataFrame. _get_location_openstreetmap is meant to be for internal usage of the package so no maintainenance can me assumed but you can use it.

from pynsee.sirene import search_sirene

test = search_sirene(variable = ["activitePrincipaleEtablissement", "codeCommuneEtablissement"],
                         pattern = ["13.20Z", "68*"], kind = 'siret', number=1000)

test_location = test.get_location()

Let me know if further investigation is needed,

raphadasilva commented 1 year ago

Thanks for the answer, Hadrien. After various resinstallations, it worked. I close the issue

Have a nice week-end

Rapha