# xgroup error in taxi and weather analysis

**URL:** <https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036>\
**Category:** Community Support\
**Tags:** pykx, imported\
**Created:** [August 24, 2024, 9:00pm UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036 "2024-08-24T21:00:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [August 24, 2024, 9:00pm UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036/1 "2024-08-24T21:00:07Z")

</div>

[https://learninghub.kx.com/forums/topic/xgroup-error-in-taxi-and-weather-analysis](https://learninghub.kx.com/forums/topic/xgroup-error-in-taxi-and-weather-analysis)

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,

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [August 27, 2024, 10:50am UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036/2 "2024-08-27T10:50:39Z")

</div>

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()
```

---

<div class="post-metadata">

**Author:** ![mwoods](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/mwoods/32/35_2.png) [@mwoods](https://forum.kx.com/u/mwoods)\
**Post date:** [August 27, 2024, 11:39am UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036/3 "2024-08-27T11:39:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [August 28, 2024, 11:28am UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036/4 "2024-08-28T11:28:04Z")

</div>

thanks!

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [August 28, 2024, 11:30am UTC](https://forum.kx.com/t/xgroup-error-in-taxi-and-weather-analysis/14036/5 "2024-08-28T11:30:39Z")

</div>

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