我有一個包含更多列的 pyspark 資料框。我將把一個短語連接到一列的每一行。例如:
"date" "other columns"
2022-01-11 19:51:37 00:00 ...
2022-01-11 20:51:55 00:00 ...
我會修改“日期”的所有行,洗掉下一??小時的內容并添加“00:00 00:00”。所以文本將變為:
"date" "other columns"
2022-01-11 19:00:00 00:00 ...
2022-01-11 20:00:00 00:00 ...
uj5u.com熱心網友回復:
鑒于它們是字串,您可以使用以下方法執行此操作
from pyspark.sql import functions
df = (df.withColumn("date", functions.concat(functions.substring('date', 0,14),
functions.lit("00:00 00:00"))))
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/421882.html
標籤:
