I had put together the below code weeks ago and it was working as intended but now when I go back to run it i'm getting an error.
import pandas as pd
import numpy as np
file1 = "List - raw .csv"
df = pd.read_csv(file1)
pd.options.display.float_format = '{:,.2f}'.format
df.loc[~df['Ship To Customer Zip'].str.contains('[A-Za-z]'), 'ZipCleaned'] = df['Ship To Customer Zip'].str.slice(stop=5)
Error: Traceback (most recent call last): File "", line 1, in File "C:\users...Python\Python37-32\lib\site-packages\pandas\core\generic.py", line 1541, in invert arr = operator.inv(com.values_from_object(self)) TypeError: bad operand type for unary ~: 'float'
The code was working as intended as of a few days ago. I also have back up code which I checked and it's generating the same error.