英文:
Pyspark - a column with time condition
问题
我想要的是一旦时间大于07:00:00,列'tatsaechlicher_einsatztag'的日期应为'einsatzdatum' + 1,如果时间小于07:00:00,则应为同一天。问题在于代码无法读取第121行的字符串。目前,始终会添加一天,因为它无法识别字符串。
英文:
I want that once the time is greater than 07:00:00, the date of the column 'tatsaechlicher_einsatztag' should be 'einsatzdatum' + 1, and if the time is less than 07:00:00, then it should be the same day. The problem here is that the code cannot read the string in line 121. Currently, one day is always added because it does not recognize the string.
答案1
得分: 1
你可以通过使用'hours'函数来实现这个。你需要从pyspark.sql中导入它,例如:
from pyspark.sql import functions as F
要执行比较,可以这样做:
F.hours(F.col("column_name")) < F.lit(7)
英文:
You can do this by using the 'hours' function. You'll need to import this from pyspark.sql e.g.
from pyspark.sql import functions as F
To actually perform the comparison it would be something like this.
F.hours(F.col("column_name")) < F.lit(7)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论