Skip to content

Commit

Permalink
Fixed merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianWeiHaoMa committed Nov 16, 2024
1 parent 0a36528 commit 0fac849
Showing 1 changed file with 119 additions and 3 deletions.
122 changes: 119 additions & 3 deletions MISOReports/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2537,12 +2537,128 @@ def parse_RT_LMPs(
def parse_sr_gfm(
res: requests.Response,
) -> pd.DataFrame:
df = pd.read_excel(
MarketHourColumn = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=3,
skiprows=4,
usecols="A",
)[:-1]

MarketHourColumn["Market Hour Ending"] = MarketHourColumn["Market Hour Ending"].astype(pandas.core.arrays.string_.StringDtype())

df1 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="B:J",
sheet_name="RT Generation Fuel Mix",
)[:-1]
shared_column_names = list(df1.columns)[:-2]

df1[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]] = df1[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]].astype(numpy.dtypes.Float64DType())

raise NotImplementedError("Parsing of this report is not yet implemented.")
df2 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="L:T",
sheet_name="RT Generation Fuel Mix",
names=shared_column_names + ["Storage", "Total MW"],
)[:-1]

df2[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]] = df2[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]].astype(numpy.dtypes.Float64DType())

df3 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="V:AC",
sheet_name="RT Generation Fuel Mix",
names=shared_column_names + ["Total MW"],
)[:-1]

df3[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Total MW"]] = df3[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Total MW"]].astype(numpy.dtypes.Float64DType())

df4 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="AG:AO",
sheet_name="RT Generation Fuel Mix",
names=shared_column_names + ["Storage", "MISO"],
)[:-1]

df4[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "MISO"]] = df4[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "MISO"]].astype(numpy.dtypes.Float64DType())

df5 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="B:J",
sheet_name="DA Cleared Generation Fuel Mix",
names=shared_column_names + ["Storage", "Total MW"],
)[:-1]

df5[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]] = df5[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]].astype(numpy.dtypes.Float64DType())

df6 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="L:T",
sheet_name="DA Cleared Generation Fuel Mix",
names=shared_column_names + ["Storage", "Total MW"],
)[:-1]

df6[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]] = df6[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "Total MW"]].astype(numpy.dtypes.Float64DType())

df7 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="V:AC",
sheet_name="DA Cleared Generation Fuel Mix",
names=shared_column_names + ["Total MW"],
)[:-1]

df7[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Total MW"]] = df7[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Total MW"]].astype(numpy.dtypes.Float64DType())

df8 = pd.read_excel(
io=io.BytesIO(res.content),
skiprows=4,
usecols="AG:AO",
sheet_name="DA Cleared Generation Fuel Mix",
names=shared_column_names + ["Storage", "MISO"],
)[:-1]

df8[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "MISO"]] = df8[["Coal", "Gas", "Nuclear", "Hydro", "Wind", "Solar", "Other", "Storage", "MISO"]].astype(numpy.dtypes.Float64DType())


df_list = [df1, df2, df3, df4, df5, df6, df7, df8]

for df in df_list:
df.insert(
loc=0,
column="Market Hour Ending",
value=MarketHourColumn["Market Hour Ending"],
)

df = pd.DataFrame({
MULTI_DF_NAMES_COLUMN: [
"RT Generation Fuel Mix Central",
"RT Generation Fuel Mix North",
"RT Generation Fuel Mix South",
"RT Generation Fuel Mix Totals",
"DA Cleared Generation Fuel Mix Central",
"DA Cleared Generation Fuel Mix North",
"DA Cleared Generation Fuel Mix South",
"DA Cleared Generation Fuel Mix Totals",
],
MULTI_DF_DFS_COLUMN: [
df1,
df2,
df3,
df4,
df5,
df6,
df7,
df8,
],
})

return df


def parse_dfal_HIST(
Expand Down

0 comments on commit 0fac849

Please sign in to comment.