Skip to content

Install & Run

Catherine Birney edited this page Sep 29, 2021 · 14 revisions

Prerequisites

  1. Python 3.7 or greater, 64-bit version - https://www.python.org/downloads/
  2. The latest version of pip. Included as a default option with Python installation.

Installation of python module

From command line, run:

pip install git+https://github.com/USEPA/[email protected]#egg=flowsa

where you can replace 'v0.3.1' with the version you wish to use under Releases.

You can test the installation by opening a Python console and entering

import flowsa

If using PyCharm, first go to:

Tools > "Python or Debug Console"

rather than using the default command terminal, otherwise you'll encounter import: command not found. If no error is returned, the libraries are installed.

Example Code

Example code is found in the examples folder.

See model.earth for example code loading, subsetting, and saving Bureau of Labor Statistics County Industry Data.

Reading Parquet Files

FlowByActivity.py and FlowBySector.py generate parquet files. In python, use pandas to read the parquet file and save in another format.

Example to save as a csv:

import pandas
# load the parquet
df = pd.read_parquet(file_name)
# maintain leading 0s in location col
df.Location = df.Location.apply('="{}"'.format)
# save output to csv with a user defined output_path
df.to_csv(output_path + '_' + file_name + ".csv", index=False)


See this stackoverflow post for a discussion on GUI tools for viewing parquets.