I am trying to convert a series of markets to uppercase so I can match with a zip dictionary. When I loop through the string and convert to uppercase, it works fine, as so:
def uppercase(series):
for string in series:
print(string.upper())
uppercase(markets.County)
But when I try to append this to a new list or with list comprehension, it fails:
def uppercase(series):
string_upper = []
for string in series:
string_upper.append(string.upper())
uppercase(markets.County)
With an attribute error that it can't convert the periods to uppercase. But it just did that in the code above.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-25-2c8a689b8491> in <module>
6 string_upper.append(string.upper())
7
----> 8 uppercase(markets.County)
<ipython-input-25-2c8a689b8491> in uppercase(series)
4
5 for string in series:
----> 6 string_upper.append(string.upper())
7
8 uppercase(markets.County)
AttributeError: 'float' object has no attribute 'upper'
This seems like a 2 second simple solution. Why is it failing when it has to append the new data?