You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been giving this a good whirl with some large data and so far things are going well. However, I've come across something, which doesn't seem quite right to me but wanted to check if this was another potential issue or maybe an improvement that could be made.
A problem occurs if you select rows based upon a value that will return you an empty table, and then try and perform other steps. For example
If you try and run this code then you will get IndexError: tuple index out of range. The problem seems to relate (and this might be my incorrect understanding) grouping by a column which doesn't exist because of the previous where removed all rows and thus all column information. A short-term fix is to break apart the above calls, and perform a len operation on the result from the where operation and then decide if to proceed.
What I would have expected to happen is it just to do nothing, and return something similar to this
| department | count |
| ---------- | ----- |
This would be similar to what you get if you just say print_table after the initial where operation.
t.where(lambda row: row['department'] is not None) \
.print_table()
Which yields
| department | job | name |
| ---------- | --- | ---- |
Also this would be more in keeping with SQL analogy as if you perform a group by on a query which the where has removed all rows then the SQL command proceeds to return you an empty result set. This would also be more python like in the way it loops through empty lists/sets
The text was updated successfully, but these errors were encountered:
If I run this on a smaller-than-usual dataset, there may not be any homicides. In such a case, I get the IndexError: tuple index out of range error, similar to what @Mr-F described above.
Hi,
I've been giving this a good whirl with some large data and so far things are going well. However, I've come across something, which doesn't seem quite right to me but wanted to check if this was another potential issue or maybe an improvement that could be made.
A problem occurs if you select rows based upon a value that will return you an empty table, and then try and perform other steps. For example
If you try and run this code then you will get
IndexError: tuple index out of range
. The problem seems to relate (and this might be my incorrect understanding) grouping by a column which doesn't exist because of the previouswhere
removed all rows and thus all column information. A short-term fix is to break apart the above calls, and perform alen
operation on the result from thewhere
operation and then decide if to proceed.What I would have expected to happen is it just to do nothing, and return something similar to this
This would be similar to what you get if you just say print_table after the initial
where
operation.Which yields
Also this would be more in keeping with SQL analogy as if you perform a
group by
on a query which thewhere
has removed all rows then the SQL command proceeds to return you an empty result set. This would also be more python like in the way it loops through empty lists/setsThe text was updated successfully, but these errors were encountered: