I am transitioning from R to Python right now and have a sample pandas dataframe as follows:
df = pd.DataFrame({'x': pd.Series([1.0, 'Joe Young', '3M-Fit']), 'y': pd.Series(['1000', '1001', '1002'], dtype=int), 'z' : pd.Series(['Henry', 'Henry','Henry'])})
x y z
0 1 1000 Henry
1 Joe Young 1001 Henry
2 3M-Fit 1002 Henry
When I look at the datatype of each row for first column it is combination of str and float:
df['x'].map(lambda x: type(x))
0 <type 'float'>
1 <type 'str'>
2 <type 'str'>
Name: x, dtype: object
What I would like to do is to print those rows of dataframe (x and y columns included) where type(x) is a float. So, in this case I would like sample output as:
x y z
0 1 1000 Henry
I looked here and here. But it either applies to complete dataframe or gives True and False values. I want to apply it to each row of a particular column of interest and want to get real values in all columns for those rows of interest.