I have a DataFrame of containing string objects which present like integers, datetimes, and floats.
The appearance of my DataFrame:
A B C D E.....................φ
1-Int NaN Str Obj Datetime NaN...............Mixed Obj
2-NaN Float Str Obj Datetime Category................NaN
3-Int Float NaN Datetime Category............Mixed Obj
. . . . . . .
. . . . . . .
. . . . . . .
Z-Int Float Str Obj NaN Category............Mixed Obj
The actual contents and structure of it:
A B C D E.....................φ
1-Str Obj NaN Str Obj Str Obj Str Obj............Mixed Obj
2- NaN Str Obj Str Obj Str Obj Str Obj................NaN
3-Str Obj Str Obj NaN Str Obj Str Obj............Mixed Obj
. . . . . . .
. . . . . . .
. . . . . . .
Z-Str Obj Str Obj Str Obj NaN Str Obj............Mixed Obj
I attempted to access the string objects to see if I could change them:
df = df.select_dtypes(includes='object').where(~(r'\d+\\\\\d+\\\\\d+'), datetime)
I wanted to see if I could detect the datetime strings and convert the string values to datetime values. I was unsuccessful at doing this because the where method does not accept strings as conditions. How can I detect datetime, ints, or floats contained inside strings and change them from string objects into their proper type?