File tree 1 file changed +24
-5
lines changed
1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change 10
10
11
11
12
12
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 :
17
16
return df
18
17
18
+ df = df .copy ()
19
+ df .index = df .index .map (str ).str .upper ()
20
+ return df
21
+
19
22
20
23
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
+
21
39
df = df .copy ()
22
40
if isinstance (cols , str ):
23
41
cols = [cols ]
24
42
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 ()
26
45
return df
27
46
28
47
You can’t perform that action at this time.
0 commit comments