pypi.org Open in urlscan Pro
2a04:4e42:400::223  Public Scan

URL: https://pypi.org/project/faostat/
Submission: On November 25 via api from US — Scanned from DE

Form analysis 3 forms found in the DOM

/search/

<form class="search-form search-form--primary" action="/search/" role="search">
  <label for="search" class="sr-only">PyPI durchsuchen</label>
  <input id="search" class="search-form__search" type="text" name="q" placeholder="Projekte suchen" value="" autocomplete="off" autocapitalize="off" spellcheck="false" data-controller="search-focus"
    data-action="keydown@window->search-focus#focusSearchField" data-search-focus-target="searchField">
  <button type="submit" class="search-form__button">
    <i class="fa fa-search" aria-hidden="true"></i>
    <span class="sr-only">Suche</span>
  </button>
</form>

/search/

<form class="search-form search-form--fullwidth" action="/search/" role="search">
  <label for="mobile-search" class="sr-only">PyPI durchsuchen</label>
  <input id="mobile-search" class="search-form__search" type="text" name="q" placeholder="Projekte suchen" value="" autocomplete="off" autocapitalize="off" spellcheck="false">
  <button type="submit" class="search-form__button">
    <i class="fa fa-search" aria-hidden="true"></i>
    <span class="sr-only">Suche</span>
  </button>
</form>

/locale/

<form action="/locale/">
  <ul>
    <li>
      <button name="locale_id" value="en" type="submit"> English </button>
    </li>
    <li>
      <button name="locale_id" value="es" type="submit"> español </button>
    </li>
    <li>
      <button name="locale_id" value="fr" type="submit"> français </button>
    </li>
    <li>
      <button name="locale_id" value="ja" type="submit"> 日本語 </button>
    </li>
    <li>
      <button name="locale_id" value="pt_BR" type="submit"> português (Brasil) </button>
    </li>
    <li>
      <button name="locale_id" value="uk" type="submit"> українська </button>
    </li>
    <li>
      <button name="locale_id" value="el" type="submit"> Ελληνικά </button>
    </li>
    <li>
      <button class="language-switcher__selected" name="locale_id" value="de" type="submit"> Deutsch </button>
    </li>
    <li>
      <button name="locale_id" value="zh_Hans" type="submit"> 中文 (简体) </button>
    </li>
    <li>
      <button name="locale_id" value="zh_Hant" type="submit"> 中文 (繁體) </button>
    </li>
    <li>
      <button name="locale_id" value="ru" type="submit"> русский </button>
    </li>
    <li>
      <button name="locale_id" value="he" type="submit"> עברית </button>
    </li>
    <li>
      <button name="locale_id" value="eo" type="submit"> Esperanto </button>
    </li>
  </ul>
</form>

Text Content

Zum Hauptinhalt springen Zur mobilen Version wechseln
Warnung Einige Funktionen sind möglicherweise ohne JavaScript nicht nutzbar.
Bitte versuchen Sie es mit aktiviertem JavaScript, falls Probleme auftreten.
⚡️🐍⚡️ Power Python with a 30% discount on PyCharm- all proceeds go to the
Python Software Foundation. Offer ends soon, so grab it today!  Get 30% off
PyCharm


PyPI durchsuchen Suche
 * Hilfe
 * Sponsoren
 * Einloggen
 * Registrieren

Menü
 * Hilfe
 * Sponsoren
 * Einloggen
 * Registrieren

PyPI durchsuchen Suche


FAOSTAT 1.1.2

pip install faostat PIP Anweisungen kopieren

Neueste Version

Veröffentlicht am: 1. Juni 2024

Faostat Python Package




NAVIGATION

 * Projekt-Beschreibung
 * Veröffentlichungs-Historie
 * Dateien zum Herunterladen


VERIFIED DETAILS

These details have been verified by PyPI

BETREUER

noemi.cazzaniga


UNVERIFIED DETAILS

These details have not been verified by PyPI

PROJEKT-LINKS

 * Source

META

 * Lizenz: MIT License (MIT)
 * Autor: Noemi Emanuela Cazzaniga
 * Schlagwörter faostat, statistics, data, economics, science
 * Benötigt: Python >=3.6

KATEGORIEN

 * Development Status
   * 5 - Production/Stable
 * Intended Audience
   * Developers
   * Financial and Insurance Industry
   * Science/Research
 * License
   * OSI Approved :: MIT License
 * Operating System
   * OS Independent
 * Programming Language
   * Python :: 3
 * Topic
   * Office/Business
   * Office/Business :: Financial
   * Scientific/Engineering
   * Scientific/Engineering :: Information Analysis
   * Utilities

OpenEDG Python Institute is a Contributing sponsor of the Python Software
Foundation.
PSF Sponsor · Served ethically

 * Projekt-Beschreibung
 * Projekt-Details
 * Veröffentlichungs-Historie
 * Dateien zum Herunterladen


PROJEKT-BESCHREIBUNG


FAOSTAT PYTHON PACKAGE

Tools to read data from Faostat API.


FEATURES

 * Read Faostat data and metadata as list of tuples or as pandas dataframe.
 * MIT license.

Warning: Versions 1.x.x still have the functions get_areas, get_years, get_items
and get_elements, for backward compatibility, but they are deprecated and will
be removed from version 2.x.x. Also the input parameter https is deprecated and
will be removed from version 2.x.x. Please use the new utility set_requests_args
instead.


DOCUMENTATION


GETTING STARTED:

Requires Python 3.6+

pip install faostat


It is available also from Anaconda.org.


READ THE LIST OF AVAILABLE DATASETS:


AS A LIST OF TUPLES:

faostat.list_datasets()


Read the available datasets and return a list of tuples. The first element of
the list contains the header line. More information on the available datasets
can be found in the official Faostat website.

Example:

>>> ld = faostat.list_datasets()
>>> ld[0]
('code', 'label', 'date_update', 'note_update', 'release_current', 'state_current', 'year_current', 'release_next', 'state_next', 'year_next')
>>> ld[1:4]
[('QCL', 'Crops and livestock products', '2022-02-17', 'minor revision', '2021-12-21 / 2022-02-17', 'final', '2020', '2022-12', 'final', '2020'),
 ('QI', 'Production Indices', '2021-03-18', '', '2021-03-18', 'final', '2019', '2022-04', 'final', '2020'),
 ('QV', 'Value of Agricultural Production', '2021-03-18', 'minor revision', '2021-03-18', 'final', '2020', '2022-04', 'final', '2019')]



AS A PANDAS DATAFRAME:

faostat.list_datasets_df()


It reads the available datasets and returns a pandas dataframe. The first
element of the list contains the header line.

More information on the available datasets can be found in the official Faostat
website.

EXAMPLE:

>>> df = faostat.list_datasets_df()
>>> df
   code                              label  ... state_next year_next
0   QCL       Crops and livestock products  ...      final      2020
1    QI                 Production Indices  ...      final      2020
2    QV   Value of Agricultural Production  ...      final      2019
3    FS  Suite of Food Security Indicators  ...      final      2021
4   SCL        Supply Utilization Accounts  ...      final      2020
..  ...                                ...  ...        ...       ...
70   FA           Food Aid Shipments (WFP)  ...                     
71   RM                          Machinery  ...                     
72   RY                  Machinery Archive  ...                     
73   RA                Fertilizers archive  ...                     
74   PA       Producer Prices (old series)  ...                     



CHECK PARAMETERS FOR A GIVEN DATASET:

Frequently you will need just a subset of a dataset, for instance only one year
or country. You will therefore use the following functions.


TO RETRIEVE THE AVAILABLE PARAMETERS FOR A GIVEN DATASET:


AS A LIST OF TUPLES:

faostat.list_pars(code)


Given the code of a dataset, it reads the parameters and returns them as a list
of tuples. The first tuple ("row") contains the header, in order: the parameter
code, the available coding systems (when applicable) and the subdimensions.
Subdimension are reported as dictionary where keys are the subdimension codes
while the values are the descriptions of the subdimensions (definitions). They
can be used to find subset of codes with get_par or get_par_df.

EXAMPLE:

>>> a = faostat.list_pars('QCL')
>>> a
[('parameter code', 'coding_systems', 'subdimensions {code: meaning}'),
 ('area', ['M49', 'FAO', 'ISO2', 'ISO3'], {'countries': 'Countries', 'regions': 'Regions', 'specialgroups': 'Special Groups'}),
 ('element', [], {'elements': 'Elements'}),
 ('item', ['CPC', 'FAO'], {'items': 'Items', 'itemsagg': 'Items Aggregated'}),
 ('year', [], {'years': 'Years'})]


In the example, you can see that for the parameter 'area' there are four
possible coding systems (default is 'FAO'). Moreover, there are subdimensions
with code name different from the parameter code.


AS A PANDAS DATAFRAME:

faostat.list_pars_df(code)


Given the code of a dataset, it reads the parameters and returns them as a
dataframe. The columns are, in order: parameter code, cding_system (when
applicable) and a dictionary with the subdimesions, represented in a dictionary
where keys are the subdimension codes while the values are the descriptions of
the subdimensions (definitions). They can be used to find subset of codes with
get_par or get_par_df.

EXAMPLE:

>>> a = faostat.list_pars('QCL')
>>> a
   parameter code                  coding_systems                                                        subdimensions {code: meaning}
0            area  ['M49', 'FAO', 'ISO2', 'ISO3']  {'countries': 'Countries', 'regions': 'Regions', 'specialgroups': 'Special Groups'}
1         element                              []                                                             {'elements': 'Elements'}
2            item                  ['CPC', 'FAO']                                   {'items': 'Items', 'itemsagg': 'Items Aggregated'}
3            year                              []                                                                   {'years': 'Years'}


In the example, you can see that for the parameter 'area' there are four
possible coding systems (default is 'FAO'). Moreover, there are subdimensions
with code name different from the parameter code.


TO RETRIEVE THE AVAILABLE VALUES OF A PARAMETER FOR A GIVEN DATASET:


AS A DICTIONARY:

faostat.get_par(code, par)


Given the code of a dataset and a parameter (or a subdimension), it reads the
values and returns a dataframe.


AS A PANDAS DATAFRAME:

faostat.get_par_df(code, par)


Given the code of a dataset and a parameter (or a subdimension), it reads the
values and returns a dataframe.

EXAMPLE, RETRIEVE THE AVAILABLE AREAS AND THEIR CODES AS A DICTIONARY:

>> import faostat
>>> y = faostat.get_par('QCL', 'area')
>>> y
{'Afghanistan': '2',
 'Albania': '3',
 'Algeria': '4',
 'Angola': '7', 
 ...}


EXAMPLE, RETRIEVE THE AVAILABLE SPECIAL GROUPS OF AREAS, AS A DATAFRAME:

>> import faostat
>>> y = faostat.get_par_df('QCL', 'specialgroups')
y
                                                label   code aggregate_type
0                       European Union (27) + (Total)   5707              +
1                        European Union (27) > (List)  5707>              >
2                 Least Developed Countries + (Total)   5801              +
3                  Least Developed Countries > (List)  5801>              >
..                                                ...    ...            ...
8         Low Income Food Deficit Countries + (Total)   5815              +
9          Low Income Food Deficit Countries > (List)  5815>              >
10  Net Food Importing Developing Countries + (Total)   5817              +
11   Net Food Importing Developing Countries > (List)  5817>              >



READ DATA FROM A DATASET:


AS A LIST OF TUPLES:

faostat.get_data(code, pars={}, coding={}, show_flags=False, null_values=False, show_notes=False, strval=True)


Given the code of a Faostat dataset, it returns the data as a list of tuples.


AS A PANDAS DATAFRAME:

faostat.get_data_df(code, pars={}, coding={}, show_flags=False, null_values=False, show_notes=False, strval=True)


To download only a subset of the dataset, you need to pass pars={key: value,
...}:

 * key: parameter code obtained with list_pars();
 * value: can be a number, a string or a list, from the codes obtained with
   get_par().

pars is optional, but recommended to avoid Timeout Error due to too large query.

If you want to download the data in a specific coding system, different from the
'FAO' default, you need to pass coding={key: value, ...}.

 * key: coding obtained with list_pars();
 * value: can be a number, a string or a list, from the codyng_systems obtained
   with get_par() for the given parameter.

Set show_flags=True if you want to download also the data flags.

Set null_values=True to download also the null data.

Set show_notes=True to download the notes.

By default, the results are kept as provided by the Faostat API, so they are all
strings (also the numbers). Set strval=False if you want the code to provide the
results as numbers.

EXAMPLE: DOWNLOAD A SUBSET OF DATA, BASED ON PARAMETERS, AS A LIST OF TUPLES,
WITH DEFAULT CODING_SYSTEM:

>>> mypars = {'element':[2312, 2313],'item':'221'}
>>> data = faostat.get_data('QCL', pars=mypars)
>>> data[40:44]
[('QCL', 'Crops and livestock products', '2', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2014', '2014', 'ha', '13703'),
 ('QCL', 'Crops and livestock products', '2', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2015', '2015', 'ha', '14676'),
 ('QCL', 'Crops and livestock products', '2', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2016', '2016', 'ha', '19481'),
 ('QCL', 'Crops and livestock products', '2', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2017', '2017', 'ha', '19793')]


EXAMPLE: DOWNLOAD A SUBSET OF DATA, BASED ON PARAMETERS, AS A LIST OF TUPLES,
WITH CHOOSEN CODING_SYSTEM:

>>> mypars = {'element':[2312, 2313],'item':'221'}
>>> mycoding = {'area': 'ISO3'}
>>> data = faostat.get_data('QCL', pars=mypars, coding=mycoding)
>>> data[40:44]
[('QCL', 'Crops and livestock products', 'AFG', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2014', '2014', 'ha', '13703'),
 ('QCL', 'Crops and livestock products', 'AFG', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2015', '2015', 'ha', '14676'),
 ('QCL', 'Crops and livestock products', 'AFG', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2016', '2016', 'ha', '19481'),
 ('QCL', 'Crops and livestock products', 'AFG', 'Afghanistan', '5312', 'Area harvested', '221', 'Almonds, with shell', '2017', '2017', 'ha', '19793')]


EXAMPLE: DOWNLOAD A SUBSET OF DATA AS NUMBERS, AS A LIST OF TUPLES:

>>> mypars = {'area': '5815',
              'element': [2312, 2313],
              'item': '221',
              'year': [2020, 2021]}
>>> data = faostat.get_data('QCL', pars=mypars, strval=False)
>>> data
[('Domain Code', 'Domain', 'Area Code', 'Area', 'Element Code', 'Element', 'Item Code', 'Item', 'Year Code', 'Year', 'Unit', 'Value'),
 ('QCL', 'Crops and livestock products', 5815, 'Low Income Food Deficit Countries', 5312, 'Area harvested', 221, 'Almonds, in shell', 2020, '2020', 'ha', 112434),
 ('QCL', 'Crops and livestock products', 5815, 'Low Income Food Deficit Countries', 5312, 'Area harvested', 221, 'Almonds, in shell', 2021, '2021', 'ha', 129916)]


EXAMPLE: DOWNLOAD A SUBSET OF DATA AS NUMBERS, AS A DATAFRAME:

>>> mypars = {'area': '5815',
              'element': [2312, 2313],
              'item': '221',
              'year': [2020, 2021]}
>>> data = faostat.get_data_df('QCL', pars=mypars, strval=False)
>>> df
  Domain Code                        Domain  Area Code  ...  Year  Unit   Value
0         QCL  Crops and livestock products       5815  ...  2020    ha  112434
1         QCL  Crops and livestock products       5815  ...  2021    ha  129916



TO SET UP A PROXY AND OTHER REQUEST ARGUMENTS:

You may need to modify the default download settings. This package uses the
[requests][req] package and allows to set some of its arguments:

 * timeout: how long to wait for the server before raising an error, in sec.
   Default is 120 sec.
 * proxies : sets the proxies. It overwrites the proxy setting of any previous
   runs of setproxy. For the Faostat API, only the https proxy is used. Default
   is None (the optional argument is not passed to the request).
 * verify : whether to verify the server’s TLS certificate, or to use a CA
   bundle. Defaults to None (the optional argument is not passed to the
   request).
 * cert : whether to use a SSL client cert file. Defaults to None (the optional
   argument is not passed to the request).

faostat.set_requests_args([timeout=120.], [proxies=None], [verify=None], [cert=None])


It returns None.

For detailed information, please refer to the documentation of the package
[requests][req_req].

EXAMPLE:

>>> import faostat
>>> mytimeout = 240.
>>> myproxy = {'https': 'http://myuser:mypass@123.45.67.89:1234'}
>>> faostat.set_requests_args(timeout=mytimeout, proxies=myproxy)


To check the settings:

faostat.get_requests_args()


It returns a dictionary with the argument names and their respective values,
exactly as they are passed to the request.


BUG REPORTS AND FEATURE REQUESTS:

Please open an issue or send a message to noemi.cazzaniga [at] polimi.it. Before
opening a new issue, please have a look at the existing issues.


DISCLAIMER:

Download and usage of Faostat data is subject to FAO's general terms and
conditions.


DATA SOURCES:

 * Faostat database: online catalog.


REFERENCES:

 * Python package pandas: Python Data Analysis Library.
 * Python package eurostat: Tools to read data from Eurostat.


HISTORY:


VERSION 1.1.2 (JUNE 2024):

 * Internal bug fix


VERSION 1.1.1 (MAY 2024):

 * Removed the functions get_areas, get_years, get_items and get_elements.
 * Implemented all codings.
 * set_requests_args and get_requests_args replace https_proxy args.
 * Changed the base url.
 * https input parameter is deprecated.


VERSION 1.0.2 (OCT 2023):

 * Bug fix: build.


VERSION 1.0.1 (OCT 2023):

 * Implemented all the parameters.
 * Prevented list_datasets to show the datasets that are not accessible
   (update_date=None).


VERSION 0.1.1 (2022):

 * First official release.


PROJEKT-DETAILS


VERIFIED DETAILS

These details have been verified by PyPI

BETREUER

noemi.cazzaniga


UNVERIFIED DETAILS

These details have not been verified by PyPI

PROJEKT-LINKS

 * Source

META

 * Lizenz: MIT License (MIT)
 * Autor: Noemi Emanuela Cazzaniga
 * Schlagwörter faostat, statistics, data, economics, science
 * Benötigt: Python >=3.6

KATEGORIEN

 * Development Status
   * 5 - Production/Stable
 * Intended Audience
   * Developers
   * Financial and Insurance Industry
   * Science/Research
 * License
   * OSI Approved :: MIT License
 * Operating System
   * OS Independent
 * Programming Language
   * Python :: 3
 * Topic
   * Office/Business
   * Office/Business :: Financial
   * Scientific/Engineering
   * Scientific/Engineering :: Information Analysis
   * Utilities



VERÖFFENTLICHUNGS-HISTORIE VERÖFFENTLICHUNGS-BENACHRICHTIGUNGEN | RSS-FEED

Diese Version


1.1.2

1. Juni 2024

1.1.1

24. Mai 2024

1.0.2

10. Okt. 2023

1.0.1

4. Okt. 2023

0.1.1

13. Apr. 2022


DATEIEN ZUM HERUNTERLADEN

Laden Sie die Datei für Ihre Plattform herunter. Wenn Sie nicht sicher sind, was
Sie auswählen sollen, lesen Sie Installation von Paketen.


QUELLE DISTRIBUTION

faostat-1.1.2.tar.gz (13.7 kB view details)

Uploaded 1. Juni 2024 Source


GEBAUTE DISTRIBUTION

faostat-1.1.2-py3-none-any.whl (9.8 kB view details)

Uploaded 1. Juni 2024 Python 3


FILE DETAILS

Details for the file faostat-1.1.2.tar.gz.


FILE METADATA

 * Download URL: faostat-1.1.2.tar.gz
 * Upload date: 1. Juni 2024
 * Size: 13.7 kB
 * Tags: Source
 * Uploaded using Trusted Publishing? No
 * Uploaded via: twine/5.1.0 CPython/3.11.8


FILE HASHES

Hash-Codes für faostat-1.1.2.tar.gz Algorithmus Hashwert SHA256
b270ab596c40cdc3ea777563384b56df01dbfcb9bcbb09cc156e51c28bcc46de Kopieren MD5
4d93ae89f6f409b9148e6f81cd9a14cd Kopieren BLAKE2b-256
ce643b0fec31599efb2469a078994c31b0527fa410322d5de51138103ef97c22 Kopieren

See more details on using hashes here.


FILE DETAILS

Details for the file faostat-1.1.2-py3-none-any.whl.


FILE METADATA

 * Download URL: faostat-1.1.2-py3-none-any.whl
 * Upload date: 1. Juni 2024
 * Size: 9.8 kB
 * Tags: Python 3
 * Uploaded using Trusted Publishing? No
 * Uploaded via: twine/5.1.0 CPython/3.11.8


FILE HASHES

Hash-Codes für faostat-1.1.2-py3-none-any.whl Algorithmus Hashwert SHA256
954aa2ac3a77ffccd1ffe5d36da225b02b09b9635d713eefa5861e92ee047aa4 Kopieren MD5
91ec8d4b5b127ce3a397693bb1fa2ecb Kopieren BLAKE2b-256
2af35d8000cb41314f0b96bf103e71ee080abd912f5673a47ed6c34892faf59c Kopieren

See more details on using hashes here.


HILFE

 * Installieren von Paketen
 * Hochladen von Paketen
 * Bedienungsanleitung
 * Project name retention
 * Häufige Fragen


ÜBER PYPI

 * PyPI Blog
 * Infrastruktur Übersicht
 * Statistiken
 * Logos und Markenzeichen
 * Unsere Sponsoren


MITWIRKEN BEI PYPI

 * Fehler und Rückmeldungen
 * Mitwirken auf GitHub
 * PyPI übersetzen
 * Sponsor PyPI
 * Entwicklungs-Anerkennungen


PYPI VERWENDEN

 * Verhaltensrichtlinien
 * Sicherheitsproblem melden
 * Privacy Notice
 * Terms of Use
 * Richtlinie zur akzeptablen Nutzung

--------------------------------------------------------------------------------

Status: All Systems Operational

Entwickelt und gepflegt von der Python-Community, für die Python-Community.
Spenden Sie noch heute!

"PyPI", "Python Package Index", and the blocks logos are registered trademarks
of the Python Software Foundation.


© 2024 Python Software Foundation
Sitemap

Zur Desktop-Version wechseln
 * English
 * español
 * français
 * 日本語
 * português (Brasil)
 * українська
 * Ελληνικά
 * Deutsch
 * 中文 (简体)
 * 中文 (繁體)
 * русский
 * עברית
 * Esperanto

Supported by


AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google
Download Analytics Microsoft PSF Sponsor Pingdom Monitoring Sentry Error logging
StatusPage Status page