Exception Handling in Pandas .apply() function
问题 If I have a DataFrame: myDF = DataFrame(data=[[11,11],[22,'2A'],[33,33]], columns = ['A','B']) Gives the following dataframe (Starting out on stackoverflow and don't have enough reputation for an image of the DataFrame) | A | B | 0 | 11 | 11 | 1 | 22 | 2A | 2 | 33 | 33 | If i want to convert column B to int values and drop values that can't be converted I have to do: def convertToInt(cell): try: return int(cell) except: return None myDF['B'] = myDF['B'].apply(convertToInt) If I only do: myDF[