My dataframe:
Cerrada | Text Analytics | Cantidad | Correctas | Erroneas | Asertividad
-- | -- | -- | -- | -- | -- | -- | --
Sin Anomalias | CR | 103 | 71 | 32 | 68.932039
Sin Anomalias | FR | 223 | 81 | 142 | 36.322870
Sin Anomalias | NC | 295 | 257 | 38 | 87.118644
Sin Anomalias | SVP | 2186 | 2053 | 133 | 93.915828
Sin Anomalias | SA | 5946 | 5578 | 368 | 93.810965
Sin Anomalias | SD | 455 | 217 | 238 | 47.692308
Sin Anomalias | TC | 77 | 8 | 69 | 10.389610
Sin Anomalias | YR | 49 | 46 | 3 | 93.877551
My code:
import matplotlib.pyplot as plt
from pysankey import sankey
import matplotlib.pyplot as plt
from pysankey import sankey
weight = df['Asertividad'].values[1:].astype(float)
sankey(left=df['Cerrada'].values[1:], right=df['Text Analytics'].values[1:], rightWeight=weight, leftWeight=weight, aspect=20, fontsize=20)
plt.show() # to display
The error thrown:
UnboundLocalError Traceback (most recent call last)
in
4 weight = df['Asertividad'].values[1:].astype(float)
5
----> 6 sankey(left=df['Cerrada'].values[1:], right=df['Text Analytics'].values[1:], rightWeight=weight, leftWeight=weight, aspect=20, fontsize=20)
7
8 plt.show() # to display
~\AppData\Roaming\Python\Python37\site-packages\pysankey\sankey.py in sankey(left, right, leftWeight, rightWeight, colorDict, leftLabels, rightLabels, aspect, rightColor, fontsize, ax)
192 # Determine positions of left label patches and total widths
193 leftWidths, topEdge = _get_positions_and_total_widths(
--> 194 dataFrame, leftLabels, 'left', aspect)
195
196 # Determine positions of right label patches and total widths
~\AppData\Roaming\Python\Python37\site-packages\pysankey\sankey.py in _get_positions_and_total_widths(df, labels, side, aspect)
296 LOGGER.debug("%s position of '%s' : %s", side, label, labelWidths)
297
--> 298 return widths, topEdge
UnboundLocalError: local variable 'topEdge' referenced before assignment
Thanks in advance !!!
My dataframe:
Cerrada | Text Analytics | Cantidad | Correctas | Erroneas | Asertividad
-- | -- | -- | -- | -- | -- | -- | --
Sin Anomalias | CR | 103 | 71 | 32 | 68.932039
Sin Anomalias | FR | 223 | 81 | 142 | 36.322870
Sin Anomalias | NC | 295 | 257 | 38 | 87.118644
Sin Anomalias | SVP | 2186 | 2053 | 133 | 93.915828
Sin Anomalias | SA | 5946 | 5578 | 368 | 93.810965
Sin Anomalias | SD | 455 | 217 | 238 | 47.692308
Sin Anomalias | TC | 77 | 8 | 69 | 10.389610
Sin Anomalias | YR | 49 | 46 | 3 | 93.877551
My code:
import matplotlib.pyplot as plt
from pysankey import sankey
import matplotlib.pyplot as plt
from pysankey import sankey
weight = df['Asertividad'].values[1:].astype(float)
sankey(left=df['Cerrada'].values[1:], right=df['Text Analytics'].values[1:], rightWeight=weight, leftWeight=weight, aspect=20, fontsize=20)
plt.show() # to display
The error thrown:
UnboundLocalError Traceback (most recent call last)
in
4 weight = df['Asertividad'].values[1:].astype(float)
5
----> 6 sankey(left=df['Cerrada'].values[1:], right=df['Text Analytics'].values[1:], rightWeight=weight, leftWeight=weight, aspect=20, fontsize=20)
7
8 plt.show() # to display
~\AppData\Roaming\Python\Python37\site-packages\pysankey\sankey.py in sankey(left, right, leftWeight, rightWeight, colorDict, leftLabels, rightLabels, aspect, rightColor, fontsize, ax)
192 # Determine positions of left label patches and total widths
193 leftWidths, topEdge = _get_positions_and_total_widths(
--> 194 dataFrame, leftLabels, 'left', aspect)
195
196 # Determine positions of right label patches and total widths
~\AppData\Roaming\Python\Python37\site-packages\pysankey\sankey.py in _get_positions_and_total_widths(df, labels, side, aspect)
296 LOGGER.debug("%s position of '%s' : %s", side, label, labelWidths)
297
--> 298 return widths, topEdge
UnboundLocalError: local variable 'topEdge' referenced before assignment
Thanks in advance !!!