赞
踩
本文参考了master苏:pyspark系列--pandas与pyspark对比
current_date()
from
- +---+----------+
- | id| date|
- +---+----------+
- | 0|2020-09-09|
- | 1|2020-09-09|
- | 2|2020-09-09|
- +---+----------+
current_timestamp()
from
- +---+--------------------+
- | id| date|
- +---+--------------------+
- | 0|2020-08-27 10:36:...|
- | 1|2020-08-27 10:36:...|
- | 2|2020-08-27 10:36:...|
- +---+--------------------+
-
date_format()
from
- +----------+
- | date|
- +----------+
- |04/08/2015|
- +----------+
to_date(), to_timestamp()
from
- +----------+
- | date|
- +----------+
- |1997-02-28|
- +----------+
-
- +-------------------+
- | dt|
- +-------------------+
- |1997-02-28 10:30:00|
- +-------------------+
-
- +-------------------+
- | dt|
- +-------------------+
- |1997-02-28 10:30:00|
- +-------------------+
year(), month(), dayofmonth()函数
from
- +----+-----+---+
- |year|month|day|
- +----+-----+---+
- |2015| 4| 8|
- +----+-----+---+
hour(), minute(), second() 函数
from
- +----+------+------+
- |hour|minute|second|
- +----+------+------+
- | 13| 8| 15|
- +----+------+------+
quarter()函数
from
- +-------+
- |quarter|
- +-------+
- | 2|
- +-------+
from
- +----------+----------+
- | d_add| d_sub|
- +----------+----------+
- |2015-04-09|2015-04-07|
- +----------+----------+
add_months()函数
from
- +----------+
- | d|
- +----------+
- |2015-05-08|
- +----------+
日期差用datediff()
月份差用months_between()
from
- +----+
- |diff|
- +----+
- | 32|
- +----+
-
- +----------+
- | months|
- +----------+
- |3.94959677|
- +----------+
next_day(),计算当前日期的下一个星期1,2,3,4,5,6,7的具体日子,属于实用函数
from
- +----------+
- | date|
- +----------+
- |2015-08-02|
- +----------+
last_day()函数
from
- +----------+
- | date|
- +----------+
- |1997-02-28|
- +----------+
更多资讯关注微信公众号:DataScienceArt,不定期分送各种小福利。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。