Skip to content
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

[PYTHON] to_pandas_series_rdd() does not work #193

Open
laldonza opened this issue May 11, 2017 · 0 comments
Open

[PYTHON] to_pandas_series_rdd() does not work #193

laldonza opened this issue May 11, 2017 · 0 comments

Comments

@laldonza
Copy link

When I try to use the method to_pandas_series_rdd of any TimeSeriesRDD, I get this error.

PicklingError: Could not serialize object: Py4JError: An error occurred while calling o231.getnewargs. Trace:
py4j.Py4JException: Method getnewargs([]) does not exist
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:326)
at py4j.Gateway.invoke(Gateway.java:272)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:214)
at java.lang.Thread.run(Thread.java:745)

I don't know if anyone else have the same problem but after searching about this error, I realized that the error was caused because of the index().to_pandas_index(), the lazy evaluation makes a spark expression been called in the map, so I rewrote the method like this using deep copy and I don't get the error anymore.

def to_pandas_series_rdd(self):    

    """ Returns an RDD of Pandas Series objects indexed with Pandas DatetimeIndexes """

    def get_index(self):
        index = self.index().to_pandas_index()
        indexDC = index.copy(name="index", deep=True)
        return indexDC

    index = get_index(self)
    return self.map(lambda x: (x[0], pd.Series(x[1], index) ) ) 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant