Replace dots in a float column with nan in Python
问题 I have a data frame df like this df = pd.DataFrame([ {'Name': 'Chris', 'Item Purchased': 'Sponge', 'Cost': 22.50}, {'Name': 'Kevyn', 'Item Purchased': 'Kitty Litter', 'Cost': '.........'}, {'Name': 'Filip', 'Item Purchased': 'Spoon', 'Cost': '...'}], index=['Store 1', 'Store 1', 'Store 2']) I want to replace the missing values in 'Cost' columns to np.nan . So far I have tried: df['Cost']=df['Cost'].str.replace("\.\.+", np.nan) and df['Cost']=re.sub('\.\.+',np.nan,df['Cost']) but neither of