# Sankey Diagram Data Preprocessing - Python

**URL:** <https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481>\
**Category:** 📊 Plotly Python\
**Created:** [February 20, 2018, 1:46pm UTC](https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481 "2018-02-20T13:46:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrewash46](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Andrewash46](https://community.plotly.com/u/Andrewash46)\
**Post date:** [February 20, 2018, 1:46pm UTC](https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481/1 "2018-02-20T13:46:19Z")

</div>

I am having a hard time understanding how to preprocess my Python Pandas dataframe to pull into a Sankey diagram script. I have a df of online consumer data with multiple rows pertaining to one consumer. The dataframe has over 50,000 consumer sample paths. Does anyone know how to approach this?

Thanks!

Andrew

---

<div class="post-metadata">

**Author:** ![mihalw28](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@mihalw28](https://community.plotly.com/u/mihalw28)\
**Post date:** [November 14, 2018, 10:22am UTC](https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481/2 "2018-11-14T10:22:48Z")

</div>

I hope you did the right approach. I’am dealing with a similar challange now (5000 rows x 10 cols data frame) and it’s definitely not a piece of cake.  
Best!

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [November 15, 2018, 10:35am UTC](https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481/3 "2018-11-15T10:35:33Z")

</div>

Hi @Andrewash46 and @mihalw28,

The pre-processing approach depends on the form of the data you’re starting with. A [Sankey diagram](https://plot.ly/python/sankey-diagram/) is designed to represent a weighted graph (nodes, edges, and weights).

You may also want to take a look at the new Parallel Categories diagram (See [https://plot.ly/python/parallel-categories-diagram/](https://plot.ly/python/parallel-categories-diagram/)). This has a superficially similar appearance to a Sankey diagram, but it’s designed to represented multi-dimensional categorical datasets.

Feel free to share more details on your dataset if you want to talk through it more,  
-Jon

---

<div class="post-metadata">

**Author:** ![mihalw28](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@mihalw28](https://community.plotly.com/u/mihalw28)\
**Post date:** [November 19, 2018, 9:58am UTC](https://community.plotly.com/t/sankey-diagram-data-preprocessing-python/8481/4 "2018-11-19T09:58:58Z")

</div>

Thanks for your response @jmmease.

Parallel categories diagram is new one for me and it looks very interesting on examples. I`ll try it with my data. Once again, thanks. 😉
