dhavalpotdar/Graph-Convolution-on-Structured-Documents

"Passing list-likes to .loc or [] with any missing labels is no longer supported. "

Opened this issue · 5 comments

	df['below_object'] = df.loc[nearest_dest_ids_vert, 'Object'].values

Because of this line I am getting this error. Any idea for avoiding this error ?

I am facing the same issue while trying this, also the code looks for label_column which is not present in csv file, if we comment that we face this issue

I also get stuck on this issue. The list "nearest_dest_ids_vert" contains value "-1" and i get the key value error. Any ideas for solving this error?

@hmtuan0315

Getting the same error. Trying to figuring out the problem. Maybe its bc of a newer pandas version?
If anyone has an idea, please comment..

I guess it worked in 2020 when the creater published the code.

edit:
solved it with replacing the lines of code with the .loc. Instead used a normal for-loop to get the values:

` below_object_list = []

    for id in nearest_dest_ids_vert:

        if id == -1:

            below_object_list.append("NULL")

        else:

            below_object_list.append(df.loc[id, 'Object'])

    df["below_object"] = below_object_list`

Now its working fine for me.

@CCAI-Eric Replacing the orginal lines of code with your code throws another Key Error for
df['side_object'] = df.loc[nearest_dest_ids_hori, 'Object'].values
"None of [Int64Index([-1, -1, -1, -1, -1, -1], dtype='int64')] are in the [index]"

do you have any idea how to overcome this one? certainly it has something to do wit loc iloc i guess?
Appreciate your help! Thanks

I suffered the same problem.
I worked with pandas >= 1.4 which is far beyond the required pandas==0.25.1.

I replaced generating nearest_dest_ids as follows.

            if len(dest_attr_vert_sorted) == 0:
                nearest_dest_ids_vert.append(src_idx)
                x_src_coords_vert.append(-1)
                y_src_coords_vert.append(-1)
                x_dest_coords_vert.append(-1)
                y_dest_coords_vert.append(-1)
                distances.append(0)

             ...

            # ========================== horizontal ========================= #
            if len(dest_attr_hori_sorted) == 0:
                nearest_dest_ids_hori.append(src_idx)
                x_src_coords_hori.append(-1)
                y_src_coords_hori.append(-1)
                x_dest_coords_hori.append(-1)
                y_dest_coords_hori.append(-1)
                lengths.append(0)