Utilities
opendsm.eemeter.utilities.io
¶
A module for assiting with input/output operations.
Copyright 2014-2025 OpenDSM contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
meter_data_from_csv(filepath_or_buffer, tz=None, start_col='start', value_col='value', gzipped=False, freq=None, **kwargs)
¶
Load meter data from a CSV file and convert to a dataframe.
This is an example of the default csv structure assumed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath_or_buffer |
str | FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str]
|
File path or object. |
required |
tz |
str | tzinfo | None
|
Timezone represented in the meter data. Ex: |
None
|
start_col |
str
|
Date period start column. |
'start'
|
value_col |
str
|
Value column, can be in any unit. |
'value'
|
gzipped |
bool
|
Whether file is gzipped. |
False
|
freq |
str | None
|
If given, apply frequency to data using |
None
|
**kwargs |
Extra keyword arguments to pass to |
{}
|
Source code in opendsm/eemeter/utilities/io.py
temperature_data_from_csv(filepath_or_buffer, tz=None, date_col='dt', temp_col='tempF', gzipped=False, freq=None, **kwargs)
¶
Load meter data from a CSV file and convert to a dataframe. Farenheit is assumed for building models.
This is an example of the default csv structure assumed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath_or_buffer |
str | FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str]
|
File path or object. |
required |
tz |
str | tzinfo | None
|
Timezone represented in the meter data. Ex: |
None
|
date_col |
str
|
Date period start column. |
'dt'
|
temp_col |
str
|
Temperature column. |
'tempF'
|
gzipped |
bool
|
Whether file is gzipped. |
False
|
freq |
str | None
|
If given, apply frequency to data using |
None
|
**kwargs |
Extra keyword arguments to pass to |
{}
|
Source code in opendsm/eemeter/utilities/io.py
meter_data_from_json(data, orient='list')
¶
Load meter data from a list of dictionary objects or a list of lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
list
|
A list of meter data, with each row representing a single record. |
required |
orient |
str
|
Format of |
'list'
|
This is an example of the default list
structure.
This is an example of the records
structure.
Returns:
Type | Description |
---|---|
DataFrame
|
DataFrame with a single column ( |
Source code in opendsm/eemeter/utilities/io.py
temperature_data_from_json(data, orient='list')
¶
Load temperature data from json to a Series. Farenheit is assumed for building models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
list
|
A list of temperature data, with each row representing a single record. |
required |
orient |
str
|
Format of |
'list'
|
This is an example of the default list
structure.
Returns:
Type | Description |
---|---|
Series
|
DataFrame with a single column ( |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in opendsm/eemeter/utilities/io.py
meter_data_to_csv(meter_data, path_or_buf)
¶
Write meter data from a DataFrame or Series to a CSV. See also pandas.DataFrame.to_csv
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
meter_data |
DataFrame | Series
|
DataFrame or Series with a |
required |
path_or_buf |
str | FilePath | WriteBuffer[bytes] | WriteBuffer[str]
|
Path or file handle. |
required |
Source code in opendsm/eemeter/utilities/io.py
temperature_data_to_csv(temperature_data, path_or_buf)
¶
Write temperature data to CSV. See also :any:pandas.DataFrame.to_csv
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
temperature_data |
Series
|
Temperature data series with :any: |
required |
path_or_buf |
str | FilePath | WriteBuffer[bytes] | WriteBuffer[str]
|
Path or file handle. |
required |