我有一个dataframe,它以文本值的形式包含一次旅行的持续时间,如下所示的driving_duration_text列中所示。在
print df
yelp_id driving_duration_text \
0 alexander-rubin-photography-napa 1 hour 43 mins
1 jumas-automotive-napa-2 1 hour 32 mins
2 larson-brothers-painting-napa 1 hour 30 mins
3 preferred-limousine-napa 1 hour 32 mins
4 cardon-y-el-tirano-miami 1 day 16 hours
5 sweet-dogs-miami 1 day 3 hours
如你所见,有些是用小时写的,有些是用天来写的。如何将此格式转换为秒?在
鉴于文本似乎遵循标准格式,这就相对简单了。我们需要把绳子分开,组合成相关的部分,然后处理它们。在
更新:
旧答案:
你可以这样做:
^{pr2}$输出:
相关问题 更多 >
编程相关推荐