KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums PyKX xgroup error in taxi and weather analysis

  • xgroup error in taxi and weather analysis

    Posted by lestat-jin on August 24, 2024 at 9:00 pm

    followed steps until calling xgroup to creat keyed table: grouped_taxi_dates, grouped_taxi_days,grouped_taxi_hours, which are running fine. but the below does not seem to return correct result: I guess the highlighted line is to count how many record/trips in each group of dates, so the print statement I added should not give 1? not sure where is the issue since I cannot access xgroup documentation… does anyone see the same issue here?

    Thanks,

    lestat-jin replied 2 weeks, 5 days ago 3 Members · 4 Replies
  • 4 Replies
  • rocuinneagain

    Member
    August 27, 2024 at 10:50 am

    Add .reset_index() when you create the tables to unkey them, then the for loop will run as you expect. For example:

    group_taxi_dates = kx.q.xgroup("pickup_date", taxi_tab).reset_index()
    • This reply was modified 2 weeks, 6 days ago by  rocuinneagain.
    • lestat-jin

      Member
      August 28, 2024 at 11:28 am

      thanks!

  • mwoods

    Administrator
    August 27, 2024 at 11:39 am

    Thanks for flagging this @lestat-jin , Rian’s correction should work for you.

    And I have now updated the notebook so new users will not run into this same issue, to pull the updated notebook you can navigate to Terminal and run git fetch and git pull to get the corrected notebook.

    • lestat-jin

      Member
      August 28, 2024 at 11:30 am

      Thanks, noticed other places reset_index() is needed for xgroup in order to plot properly in addition to the one reported, code updated manually.

Log in to reply.