# How to make data pass through: pandas.errors.InvalidIndexError: (slice()...)

**URL:** <https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [September 11, 2022, 10:18pm UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846 "2022-09-11T22:18:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![topotaman](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/topotaman/32/22455_2.png) [@topotaman](https://community.plotly.com/u/topotaman)\
**Post date:** [September 11, 2022, 10:18pm UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/1 "2022-09-11T22:18:28Z")

</div>

I’ve reached a point where I don’t know what else to do.

I have this df

```auto
dff8df !!!0 WWSF VPIP VPIP VPIP
0 52.0 38.64 38.64 38.64
1 62.0 50.00 50.00 50.00
2 73.0 56.25 56.25 56.25
3 99.0 23.08 23.08 23.08
4 30.0 41.67 41.67 41.67
.. ... ... ... ...
540 50.0 18.75 18.75 18.75
541 99.0 26.32 26.32 26.32
542 50.0 28.57 28.57 28.57
543 83.0 14.29 14.29 14.29
544 57.0 38.89 38.89 38.89

[545 rows x 4 columns]

```

and this code:

```auto
print("dff8df",dff8)

    figure = px.scatter(data_frame=dff8,
                   x=dff8[:,drop1],
                   y=dff8[:,drop2],
                   color=dff8[:,drop4],
                   size=dff8[:,drop3],
                   trendline="ols",
                   trendline_color_override="red",
                   title="%s vs %s"%(drop1, drop2),
                   )

```

and it gives this error with plotly in python:

```auto
pandas.errors.InvalidIndexError: (slice(None, None, None), 'VPIP')

```

How can I solve this problem?

---

<div class="post-metadata">

**Author:** ![3d65](https://avatars.discourse-cdn.com/v4/letter/3/e99b99/32.png) [@3d65](https://community.plotly.com/u/3d65)\
**Post date:** [September 12, 2022, 12:00am UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/2 "2022-09-12T00:00:23Z")

</div>

Could you provide more information on drop1, drop2, drop3, drop4, and dff8.columns?

---

<div class="post-metadata">

**Author:** ![topotaman](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/topotaman/32/22455_2.png) [@topotaman](https://community.plotly.com/u/topotaman)\
**Post date:** [September 12, 2022, 11:32am UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/3 "2022-09-12T11:32:27Z")

</div>

drop1,drop2… are the names of the columns … and dff8 (printed dff8df) is the df

---

<div class="post-metadata">

**Author:** ![3d65](https://avatars.discourse-cdn.com/v4/letter/3/e99b99/32.png) [@3d65](https://community.plotly.com/u/3d65)\
**Post date:** [September 12, 2022, 4:59pm UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/4 "2022-09-12T16:59:02Z")

</div>

I meant could you give the actual values you have set to those variables, and list what output you get for executing `dff8.columns`? It’s strange that you have multiple columns with the same name. Try giving each column a unique name.

---

<div class="post-metadata">

**Author:** ![topotaman](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/topotaman/32/22455_2.png) [@topotaman](https://community.plotly.com/u/topotaman)\
**Post date:** [September 12, 2022, 5:47pm UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/5 "2022-09-12T17:47:36Z")

</div>

I found a solution.

I droped columns, and put the names of the columns (drop1,2,3 … they are an argument of a callback) to list …

but now, with another chart, I’m getting a problem, because with only 1 column, I cant do a .tolist

I used this, to solve first chart:

```auto
drop1, drop2, drop3, drop4, drop5 = dfff2.columns[0:5].tolist()

```

---

<div class="post-metadata">

**Author:** ![3d65](https://avatars.discourse-cdn.com/v4/letter/3/e99b99/32.png) [@3d65](https://community.plotly.com/u/3d65)\
**Post date:** [September 12, 2022, 5:58pm UTC](https://community.plotly.com/t/how-to-make-data-pass-through-pandas-errors-invalidindexerror-slice/67846/6 "2022-09-12T17:58:03Z")

</div>

This is a bit outside of the scope of this forum, but for a pandas series, you can get the “column” name by calling `dfff3.name`. Also, you shouldn’t need to call `to_list()` for drops 1-4 either.
