【问题标题】:Explain the meaning of the .filter code in python解释python中.filter代码的含义
【发布时间】:2020-06-22 05:45:43
【问题描述】:

我是 Bigdata 和 Python 的新手。请解释一下

的意思
.filter("year*10000+month*100+day between {0} and {1}".format(start,end))

【问题讨论】:

  • 你忘记"了吗?他们不匹配(只有一个)
  • 是的,但是你能解释一下.filter("year*10000+month*100+day between {0} and {1}".format(start,end))的含义吗
  • 这能回答你的问题吗? How to use filter, map, and reduce in Python 3

标签: python pyspark


【解决方案1】:

以下代码的作者

.filter("year*10000+month*100+day between {0} and {1}".format(start, end))

尝试从数据框中筛选出startend 日期之间的行。

显然作者没有“日期”列,因此他们从yearmonthday 列中创建了一个日期,例如。 G。如果 year = 2020month=10day=15,则产品为日期 20201015。也许,当等式中有括号时会有所帮助:

.filter("(year * 10000) + (month * 100) + day between {0} and {1}".format(start, end))

但是,这段代码是错误的,因为从一月到九月,你不能这样设置日期,所以我建议重写它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-11
    • 2014-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多