Skip to content

Commit

Permalink
* nemo/nem.py: Re-work to eliminate the following deprecation warning
Browse files Browse the repository at this point in the history
  from Pandas:

  FutureWarning: Support for nested sequences for 'parse_dates' in
  pd.read_csv is deprecated. Combine the desired columns with
  pd.to_datetime after parsing instead.
  • Loading branch information
bje- committed Jan 25, 2024
1 parent 2bde735 commit 2fd7c5d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nemo/nem.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
raise ConnectionError(f'HTTP {resp.status_code}: {url}')
traceinput = io.StringIO(resp.text)

demand = pd.read_csv(traceinput, comment='#', sep=',',
parse_dates=[['Date', 'Time']], index_col='Date_Time')
demand = pd.read_csv(traceinput, comment='#', sep=',')
# combine Date and Time columns into a new Date_Time column, make this
# the index column and then drop the original Date and Time columns
demand['Date_Time'] = \
pd.to_datetime(demand['Date'] + ' ' + demand['Time'])
demand.set_index('Date_Time', inplace=True)
demand.drop(columns=['Date', 'Time'], inplace=True)

# Check for date, time and n demand columns (for n regions).
assert len(demand.columns) == regions.NUMREGIONS
Expand Down

0 comments on commit 2fd7c5d

Please sign in to comment.