I have a column in a dataframe with two data types, like this:
25                3037205
26    2019-09-04 19:54:57
27    2019-09-09 17:55:45
28    2019-09-16 21:40:36
29                3037206
30    2019-09-06 14:49:41
31    2019-09-11 17:17:11
32                3037207
33    2019-09-11 17:19:04
I'm trying to slice it and build a new data frame like this:
26    3037205    2019-09-04 19:54:57
27    3037205    2019-09-09 17:55:45
28    3037205    2019-09-16 21:40:36
29    3037206    2019-09-06 14:49:41
30    3037206    2019-09-11 17:17:11
31    3037207    2019-09-11 17:19:04
I can't find how to slice between numbers "no datetype".
Some ideas?
Thx!
Another approach:
s = pd.to_numeric(df['col1'], errors='coerce')
df.assign(val=s.ffill().astype(int)).loc[s.isnull()]
Output:
                   col1      val
26  2019-09-04 19:54:57  3037205
27  2019-09-09 17:55:45  3037205
28  2019-09-16 21:40:36  3037205
30  2019-09-06 14:49:41  3037206
31  2019-09-11 17:17:11  3037206
33  2019-09-11 17:19:04  3037207
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With