X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 08 Jan 2016 04:01 PM by  anon
IDL to Python Bridge - _iLocIndexer
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
08 Jan 2016 04:01 PM
    When using the IDL to Python bridge in IDL 8.5 and working with a "pandas" dataframe, I am unable to use the .iloc["index_number"] function that I can use in python. For example, with my dataframe, df, I am unable to run: df.iloc[0] to return the row of index [0]. I can return the columns by calling df.["my_column_name"], but I am looking to return a row of my dataframe. The error that I get is: %Python: Unable to index object of type: "_iLocIndexer" Does anyone know why I keep getting this error on the IDL side? Thanks.

    Zachary Norman



    Basic Member


    Posts:173
    Basic Member


    --
    11 Jan 2016 03:13 PM
    Hi Malia, Could you answer the following questions so we could better understand your problem? 1)What is your operating system and version of IDL? i.e. IDL 8.5.1 on Windows 7 65 bit 2) What Python are you using? i.e. Anaconda with Python 2.7 3) Do you have a small, self contained example which illustrates the problem you are seeing? Thanks in advance for the extra information! -Zach (VIS)

    Deleted User



    New Member


    Posts:
    New Member


    --
    22 Jan 2016 01:01 PM
    Hi Zach, Thanks for your reply! Here's the info: 1) IDL 8.5 and IDL 8.5.1 on RHEL6.4, 64 bit 2) Anaconda with Python 2.7 3) Here's the same lines of code that I tested with both 8.5 and 8.5.1. I got the same error for both: pd = python.import('pandas') df = pd.DataFrame(data=[[1,2],[3,4]], columns = ['c1','c2']) x = df.iLoc[0] % Python : Unable to index object of type: "_iLocIndexer" When I run these same codes but use the python notation, the iLoc call does work. >>> import pandas as pd >>> df = pd.DataFrame(data=[[1,2],[3,4]], columns = ['c1','c2']) >>> print (df) c1 c2 0 1 2 1 3 4 >>> x=df.iLoc[0] >>>print(x) c1 1 c2 2 Name: 0, dtype: int64 Hope that brings some insight! -Malia
    You are not authorized to post a reply.