Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
groupby and window function
#1
test.groupBy('symbol','tradingDay',Window('timestamp','5 min')).agg({'open':'first','high':'max','low':'min','close':'last','volume':'sum'}).withColumnRenamed('first(open)',"Open").withColumnRenamed('max(high)',"High").withColumnRenamed('min(low)',"Low").withColumnRenamed('last(close)',"Close").withColumnRenamed('sum(volume)',"Volume").show()

When running the above code getting below error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object() takes no parameters

My actual task is to display max or min data in 5 min window interval

Kindly help
Reply
#2
Please post runnable code snippet in Python code tags and full error traceback in error tags. You can find help here. We can't help much with what you have posted thus far.
Reply
#3
test.groupBy('symbol','tradingDay',Window('timestamp','5 min')).agg({'open':'first','high':'max','low':'min','close':'last','volume':'sum'}).withColumnRenamed('first(open)',"Open").withColumnRenamed('max(high)',"High").withColumnRenamed('min(low)',"Low").withColumnRenamed('last(close)',"Close").withColumnRenamed('sum(volume)',"Volume").show()
Reply
#4
do you REALLY think this is runnabe snippet?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,611 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,131 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Use of groupby in a function with Pandas Paulman 0 928 Dec-03-2021, 04:56 PM
Last Post: Paulman
  Question about the groupby function new_to_python 7 3,136 Feb-09-2020, 07:52 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020