Skip to content

Commit 4e0570b

Browse files
committed
fixes #9
1 parent 840f38b commit 4e0570b

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

swmmnetwork/scenario.py

+24-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,38 @@
1010

1111

1212
def _upper_case_index(df):
13-
df = df.copy()
14-
if len(df) > 0:
15-
return df.set_index(df.index.str.upper())
16-
else:
13+
"""Converts a pandas.DataFrame.index to an uppercase string
14+
"""
15+
if len(df) == 0:
1716
return df
1817

18+
df = df.copy()
19+
df.index = df.index.map(str).str.upper()
20+
return df
21+
1922

2023
def _upper_case_column(df, cols):
24+
"""Converts contents of pandas.Series to uppercase string
25+
26+
Parameters
27+
----------
28+
df : pandas.DataFrame()
29+
cols : string or list
30+
column names that will be converted to uppercase
31+
32+
Returns
33+
-------
34+
pandas.DataFrame()
35+
"""
36+
if len(df) == 0:
37+
return df
38+
2139
df = df.copy()
2240
if isinstance(cols, str):
2341
cols = [cols]
2442
for col in cols:
25-
df[col] = df[col].str.upper()
43+
if col in df.columns:
44+
df[col] = df[col].map(str).str.upper()
2645
return df
2746

2847

0 commit comments

Comments
 (0)