iobis / pyobis

OBIS Python client
https://iobis.github.io/pyobis
MIT License
15 stars 10 forks source link

improve MoF accessiblity #14

Closed 7yl4r closed 2 years ago

7yl4r commented 2 years ago

GSoC objective

ayushanand18 commented 2 years ago

I had a doubt regarding migration to the new API. Although I have modified existing modules per the docs on Swagger, I couldn't find a corresponding endpoint for pyobis/occurrence/obisDownload. Has it deprecated? ref

ayushanand18 commented 2 years ago

Because I think the user might also save occurrence records through occurrence.search().

MathewBiddle commented 2 years ago

just for reference

import requests
import pandas as pd

response = requests.get("https://api.obis.org/occurrence?scientificname=Abra&mof=true&hasextensions=MeasurementOrFact")
results = response.json()["results"]

pd.io.json.json_normalize(results, "mof", ["scientificName", "eventDate"])
ayushanand18 commented 2 years ago

just for reference

I'm utilizing this function behind occurrences.search() For the function call:

from pyobis import occurrences as occ
occ.search(scientificname="Abra",mof=True,hasextensions="MeasurementOrFact")

We get the output:

[  measurementDeterminedBy measurementAccuracy measurementValue  ... scientificName   eventDate                                    id
0                    None                None               12  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
1                    None                None             0.38  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
2                    None                None            120.0  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
3                    None                None               29  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
4                    None                None           1000.0  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
5                    None                None           1000.0  ...    Abra nitida  2013-05-31  00002fb8-f39d-4c36-b3d5-87c1f822545a
.....
.....

[17 rows x 17 columns],    measurementDeterminedBy measurementAccuracy  ...   eventDate                                    id
.....
.....
74                    None                None  ...  1998-03-19  0006ade1-e2dd-434f-9a79-f4fbad93acd5
75                    None                None  ...  1998-03-19  0006ade1-e2dd-434f-9a79-f4fbad93acd5
76                    None                None  ...  1998-03-19  0006ade1-e2dd-434f-9a79-f4fbad93acd5
77                    None                None  ...  1998-03-19  0006ade1-e2dd-434f-9a79-f4fbad93acd5
78                    None                None  ...  1998-03-19  0006ade1-e2dd-434f-9a79-f4fbad93acd5

[18 rows x 17 columns]]

Part of the output snippet is clipped to reduce length. Does this solve what we were looking for?