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] Conversion of pandas.SparseArray columns in pandas.DataFrames to pyarrow.Table and back #22705

Closed
asfimport opened this issue Aug 22, 2019 · 1 comment

Comments

@asfimport
Copy link

We would like to convert sparse columns from Pandas to Arrow:

import numpy as np
import pandas
import pyarrow

arr = pandas.Series([1, 2, 3])
sparr = pandas.SparseArray(np.array([1, 0, 0], dtype='int64'))
df = pandas.DataFrame({'sparr': sparr, 'arr': arr})

table = pyarrow.table(df)
df == table.to_pandas()

I assume pandas.SparseArray is a 1D sparse COO Tensor that would map to pyarrow.SparseTensorCOO.

Reporter: Rok Mihevc / @rok
Watchers: Rok Mihevc / @rok

Note: This issue was originally created as ARROW-6327. Please see the migration documentation for further details.

@asfimport
Copy link
Author

Antoine Pitrou / @pitrou:
Unfortunately a Arrow sparse tensor cannot be a Table column. Suggest closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant