Skip to content

A python library that uses API interface to obtain USDA/NASS Quick Stat data

License

Notifications You must be signed in to change notification settings

typing233/usda_quickstats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

usda_quickstats

A python library that uses API interface to obtain USDA/NASS Quick Stat data


Introduction

provides a simplified interface to access data from the USDA's Quick Stats API. The library is designed to fetch agricultural data, process it, and return it in a user-friendly format.

Installation

To use this library, you need Python installed on your machine. The library depends on requests and pandasandusda_stat, which can be installed using pip:

pip install requests pandas
pip install usda_quickstats

Usage

Import the library into your Python script to start using its functionalities.

import usda_quickstats

Get API_KEY

First go to USDA/NASS Quick Stats to get API_KEY Then use KEY_init("your api key") to complete the configuration of API_KEY

Functions

The library offers the following primary functions:

  1. get_data(params): Fetches specific data based on query parameters. Returns a pandas DataFrame.
  2. get_par(par): Returns possible values for a given column or header name in a DataFrame.
  3. get_counts(params): Retrieves the count of rows for queried data.

Examples

Fetching Data

params = {"commodity_desc": "CORN", "year": 2020}
data = usda_quickstats.get_data(params)
print(data)

Getting Parameter Values

parameter_values = usda_quickstats.get_par("commodity_desc")
print(parameter_values)

Getting Counts

params = {"commodity_desc": "CORN", "year": 2020}
count = usda_quickstats.get_counts(params)
print(f"Number of records: {count}")

Related link

API usage documentation

About

A python library that uses API interface to obtain USDA/NASS Quick Stat data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages