-4

I am new to Bigdata and Python. Kindly explain the meaning of

.filter("year*10000+month*100+day between {0} and {1}".format(start,end))
user4157124
  • 2,809
  • 13
  • 27
  • 42
Swati
  • 21
  • 1
  • 3
  • 2
    Did you forget a `"`? They don't match (there is only one) – Swedgin Mar 10 '20 at 10:32
  • Yes, but can you explain the meaning of .filter("year*10000+month*100+day between {0} and {1}".format(start,end)) – Swati Mar 10 '20 at 10:35
  • Does this answer your question? [How to use filter, map, and reduce in Python 3](https://stackoverflow.com/questions/13638898/how-to-use-filter-map-and-reduce-in-python-3) – Bram Vanroy Mar 10 '20 at 10:41

1 Answers1

2

The author of the following code

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

tries to filter the rows from data frame that are between start and end date.

Obviously the author does not have a column "date", so they make a date out of year, month, and day columns, e. g. if year = 2020, month=10, and day=15, the product is date 20201015. Maybe, it would be helpful, when there are parenthesis in the equation:

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

However, this code is wrong, because you cannot make the date like this for months from January to September, so I would recommend to rewrite it.

h4z3
  • 5,265
  • 1
  • 15
  • 29
Jaroslav Bezděk
  • 6,967
  • 6
  • 29
  • 46