Python pandas: how to obtain the datatypes of objects in a mixed-datatype column?
问题 Given a pandas.DataFrame with a column holding mixed datatypes, like e.g. df = pd.DataFrame({'mixed': [pd.Timestamp('2020-10-04'), 999, 'a string']}) I was wondering how to obtain the datatypes of the individual objects in the column (Series)? Suppose I want to modify all entries in the Series that are of a certain type, like multiply all integers by some factor. I could iteratively derive a mask and use it in loc , like m = np.array([isinstance(v, int) for v in df['mixed']]) df.loc[m, 'mixed