Java arrays passed to python script can't be passed to pandas.DataFrame
See original GitHub issueI have a double array in java. When i print the array it shows like:
[6.390933837890625, 6.412708740234375, 6.383675537109375, 6.398192138671875, 6.40907958984375, 6.40907958984375, 6.416337890625, 6.4054504394531255, 6.40907958984375.....]
I pass it as arg to a python script func:
Python py = Python.getInstance();
PyObject pyObject=py.getModule("test");
pyObject.callAttr("showArr",darr);
Where my test.py is:
def showArr(arr):
print(arr)
in python o/p it shows:
jarray('D')([6.390933837890625, 6.412708740234375, 6.383675537109375, 6.398192138671875, .......])
Because of this am not being able to call pandas.DataFrame(arr)
When i print a simple array in python it prints fine:
>>> arr=[1,2,3]
>>> print(arr)
[1, 2, 3]
Why does this jarray('D')
gets prepended when i pass the double array to the py script?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
python pandas dataframe, is it pass-by-value ... - Stack Overflow
The short answer is, Python always does pass-by-value, but every Python variable is actually a pointer to some object, so sometimes it looks ......
Read more >25. Accessing and Changing values of DataFrames
This chapter of our Pandas and Python tutorial will show various ways to access and change selectively values in Pandas DataFrames and Series....
Read more >Different ways to create Pandas Dataframe - GeeksforGeeks
Method #8: Creating DataFrame from Dictionary of series. To create DataFrame from Dict of series, dictionary can be passed to form a DataFrame....
Read more >Python Pandas Series - javatpoint
Before creating a Series, firstly, we have to import the numpy module and then use array() function in the program. If the data...
Read more >Load a pandas DataFrame | TensorFlow Core
Read data using pandas; A DataFrame as an array ... When you pass the DataFrame as the x argument to Model.fit , Keras...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
jarray
is being printed to indicate the object type, just like a Numpy array is printed asarray(...)
.I assume the error you got when passing the array to
pandas.DataFrame
wasTypeError: __getbuffer__ is not implemented for double[]
. This will be fixed in the next version of Chaquopy.Meanwhile, you can work around it by writing
pandas.DataFrame(list(arr))
.This issue is fixed in Chaquopy 10.0.1, except for the 1-dimensional case mentioned in the previous comment.
To upgrade, edit your app’s top-level build.gradle file and change the version number of
com.chaquo.python:gradle
.