-
Notifications
You must be signed in to change notification settings - Fork 19
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
Retrieve loaded data as pandas.DataFrame #7
Comments
Honestly, I'm not that familiar with pandas. I have to look into more, but the simplest solution to add pandas as an extra to the module, and inherit a new Reader/Writer from the existing ones with methods that can read and write pandas dataframes. There's probably a need for special converter functions for pandas' special types as well. As you've already noticed, my goal with this library is to be a simple ORC reader and writer with the smallest overhead as possible. A few smaller tasks are on my todo list now, but I'm not against the idea. The best would be, if someone with a better knowledge of pandas could contribute. 😉 |
Therefore, what do you suggest to solve this issue? These are the options I guess:
Let me know what is your concern on this and then I could make a PR related to that. |
You're probably right, separate classes for reading and writing are overkill. Maybe two simple functions defined in a submodule could be sufficient enough. I don't want to add pandas as a default requirement to the module. |
OK so you prefer to add functions/methods for that, but not to require pandas to use pyorc. I can add this behavior without adding Panda as a requirement, and raise an error if Pandas is not installed, but that will be a very bad practice. Therefore, the best option will be to just add an example with Pandas for start, and if the example is not enough you could consider expanding the scope of pyorc to be more integrated with Pandas (which is my suggestion, since it's a pretty common requirement in most of data processing libraries). Let me know your thoughts and I can make a PR from that (either adding an example or adding methods with Pandas) |
I think an example would be great as a start. A PR about that would be much appreciated. Thank you. |
Can someone please include a short example of how to use converters in the Reader? I tried really hard to figure this out but I couldn't. I'm reading a file like this where orc_bytes is of class bytes: |
This is what I have so far but it is not doing any conversion: import numpy as np
import pyorc
from pyorc.converters import ORCConverter
class TypeConverter(ORCConverter):
@staticmethod
def from_orc(decimal_input):
return np.array(decimal_input, dtype=float)
orc = pyorc.Reader(fileo=io.BytesIO(orc_bytes), converters={pyorc.TypeKind.DECIMAL: TypeConverter}) Any suggestions?! |
I updated the docs about ORCConverter Your converter above should return a numpy array with a float in it, for every item in a decimal ORC column. |
@noirello Thanks a lot! Highly appreciated. |
I think this library could be a great alternative to pyarrow and pyspark to easily read and write ORC files without requiring a big library to just achieve that (not to mention the current issues that pyarrow is having, and the overhead of loading a SparkSession just to read/write data). Therefore, in order to make it usable in most of data processing application, an easy connection with Pandas (the most popular library for local processing of tabular data) would be convenient.
I'm new using this library, but I was evaluating two options:
So far, I've solved that through this snippet (from what I could understand of the library):
The text was updated successfully, but these errors were encountered: