This repository was archived by the owner on Mar 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Detailed formatcheck.py documentation
echang97 edited this page Jul 1, 2019
·
23 revisions
Parameter(s):
- key - Item to be added or modified
- value - Unit of measurement to be associated with key
- dictionary - The Dictionary that this is being applied to
If key is already in the dictionary, add the value to the set associated with the key
Otherwise, add the associate the new key with a new set containing only value
[Ex 1.] key = "Gas", value = "mcf" -> { "Gas": {"mcf"} }
[Ex 2.] key = "Geothermal - Electrical Generation", value = "Kilowatt Hours" -> { "Geothermal - Electrical Generation": {"Kilowatt Hours"} }
key = "Geothermal - Electrical Generation", value = "Thousands of Pounds" -> { "Geothermal - Electrical Generation": {"Kilowatt Hours", "Thousands of Pounds"} }
Parameter(s):
- cols - Columns from Pandas DataFrame Checks cols for "Commodity" or "Product"
Returns "n/a" if "Commodity" and "Product" are both present or both missing
Otherwise it returns whichever is present
[Ex 1.] cols = ["Commodity"] -> returns "Commodity"
[Ex 2.] cols = ["Product"] -> returns "Product"
[Ex 3.] cols = ["Commodity", "Product"] -> returns "n/a"
Parameter(s):
- name - Name of the Excel file
Field(s):
- lower - name in all lowercase letters
- prefixes = ["cy","fy","monthly","company","federal","native","production","revenue","disbribution"]
Returns a String based on the Excel file given
If any entries from prefixes are found in name, they will be added to the final String
[Ex] name = "federal_production_CY03-18" -> returns "cyfederalproduction_"
Parameter(s):
- string - String to be split
Returns a List of Strings separated either by the right-most opening parentheses "(" or the left-most comma ","
[Ex 1] string = "Gas (mcf)" -> ["Gas", "mcf"]
[Ex 2] string = "Geothermal - Electrical Generation, Kilowatt Hours" = ["Geothermal - Electrical Generation", "Kilowatt Hours"]
[Ex 3] string = "Geothermal - sulfur" = ["Geothermal - sulfur", ""]
Constructor: When passed a DataFrame, it will set the following variables: header, unit_dict, and field_dict
Parameter(s):
- file - A Pandas DataFrame
Returns column names as a List