-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Iterableiterator #12173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterableiterator #12173
Conversation
| see #9496 |
pandas/compat/__init__.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to pandas/io/common.py, inherit from object, call this BaseIterable, raise AbstractMethodError for __next__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a parent class of Boto and UTFReader as well in`io/common.py``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also incorporate elements of TableIterator in io/pytables.py (and make this a sub-class)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseIterable or BaseIterator? True, it makes an iterable out of an iterator, but most iterables will not be iterators.
pandas/compat/__init__.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inherit from object?
c14e7d0 to 5e094a4 Compare |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each chunk has an index restarting from 0 (also in master). Isn't this a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that shouldn't be the case
In [46]: s = DataFrame({'A' : range(10)}).to_csv(None) In [47]: s Out[47]: ',A\n0,0\n1,1\n2,2\n3,3\n4,4\n5,5\n6,6\n7,7\n8,8\n9,9\n' In [48]: pd.read_csv(StringIO(s),index_col=0) Out[48]: A 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 In [49]: list(pd.read_csv(StringIO(s),index_col=0,chunksize=4)) Out[49]: [ A 0 0 1 1 2 2 3 3, A 4 4 5 5 6 6 7 7, A 8 8 9 9] There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean when the index is not loaded:
In [7]: list(pd.read_csv(StringIO(s), chunksize=4)) Out[7]: [ Unnamed: 0 A 0 0 0 1 1 1 2 2 2 3 3 3, Unnamed: 0 A 0 4 4 1 5 5 2 6 6 3 7 7, Unnamed: 0 A 0 8 8 1 9 9] Wouldn't we prefer a consistent index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm yes I agree
you'd have to keep state in the in the iterators I think though -
I do this is HDFStore iirc
but might be a bit non trivial
if u think u can fix easily - go ahead
otherwise create an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'd like to do it but it probably won't be immediate: #12185 .
| ok on doing |
pandas/io/common.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AbstractMethodError(self)
5e094a4 to ab8556d Compare b8f2582 to 36a7f62 Compare | I removed edits to |
36a7f62 to 5da8699 Compare pandas/io/tests/test_common.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add tests for read_stata & read_sas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, done
5da8699 to 04f7280 Compare 04f7280 to 88b5b57 Compare
If the approach is not overkill, it can be used also in
UTF8RecoderandUnicodeReaderfrompandas/common/io.py. Closes #12153.