Convert string into dates in pandas dataframe and handle bad values

Just coerce and dropna to get rid of it. pd.to_datetime(df['lastSaleDate'],format='%Y%m%d',errors='coerce')