I am trying to use plotly express to chart time series data.
I am receiving this error.There isn't any boolean values in my code so I don't understand why it isn't able to crunch this code.
ValueError: The truth value of a Index is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
I've looked at the data type of the dataframe and transposed and tried editing the time axis data. Dtype is dtype('0').
import pandas as pd
import numpy as np
import plotly_express as px
df = pd.read_excel('FreewayFDSData.xlsx', 'Volume')
df = df.set_index("Row Labels")
detector =df.columns
time = df.index
px.scatter(df, x=detector,y=time)

End result is unfortunately the error code.
https://www.plotly.express/ <-- this is plotly express tutorial i am following.
df.head().to_dict()
{'3674S_P1': {'00:00 - 00:15': 88.0,
  '00:15 - 00:30': 116.0,
  '00:30 - 00:45': 84.0,
  '00:45 - 01:00': 68.0,
  '01:00 - 01:15': 76.0},
 '3674S_P0': {'00:00 - 00:15': 88.0,
  '00:15 - 00:30': 116.0,
  '00:30 - 00:45': 76.0,
  '00:45 - 01:00': 68.0,
  '01:00 - 01:15': 76.0},
 '3674M_P1': {'00:00 - 00:15': 84.0,
  '00:15 - 00:30': 108.0,
  '00:30 - 00:45': 68.0,
  '00:45 - 01:00': 68.0,
  '01:00 - 01:15': 72.0},
 '3674M_P0': {'00:00 - 00:15': 92.0,
  '00:15 - 00:30': 108.0,
  '00:30 - 00:45': 68.0,
  '00:45 - 01:00': 68.0,
  '01:00 - 01:15': 72.0},
 '3674EL_P1': {'00:00 - 00:15': 96.0,
  '00:15 - 00:30': 112.0,
  '00:30 - 00:45': 64.0,
  '00:45 - 01:00': 64.0,
  '01:00 - 01:15': 88.0},
 '3674EL_P0': {'00:00 - 00:15': 108.0,
  '00:15 - 00:30': 124.0,
  '00:30 - 00:45': 68.0,
  '00:45 - 01:00': 80.0,
  '01:00 - 01:15': 100.0},
 '14549IB_P1': {'00:00 - 00:15': 380.0,
  '00:15 - 00:30': 412.0,
  '00:30 - 00:45': 380.0,
  '00:45 - 01:00': 328.0,
  '01:00 - 01:15': 320.0},
 '14549IB_P0': {'00:00 - 00:15': 376.0,
  '00:15 - 00:30': 408.0,
  '00:30 - 00:45': 376.0,
  '00:45 - 01:00': 328.0,
  '01:00 - 01:15': 328.0},
 '14548IB_P1': {'00:00 - 00:15': 464.0,
  '00:15 - 00:30': 508.0,
  '00:30 - 00:45': 448.0,
  '00:45 - 01:00': 408.0,
  '01:00 - 01:15': 376.0},
 '14548IB_P0': {'00:00 - 00:15': 464.0,
  '00:15 - 00:30': 508.0,
  '00:30 - 00:45': 444.0,
  '00:45 - 01:00': 404.0,
  '01:00 - 01:15': 376.0},
 '14547IB_P1': {'00:00 - 00:15': 501.33333333333337,
  '00:15 - 00:30': 528.0,
  '00:30 - 00:45': 501.33333333333337,
  '00:45 - 01:00': 432.0,
  '01:00 - 01:15': 437.33333333333337},
 '14547IB_P0': {'00:00 - 00:15': 460.0,
  '00:15 - 00:30': 520.0,
  '00:30 - 00:45': 440.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 380.0},
 '14546IB_P1': {'00:00 - 00:15': 468.0,
  '00:15 - 00:30': 536.0,
  '00:30 - 00:45': 440.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 380.0},
 '14546IB_P0': {'00:00 - 00:15': 464.0,
  '00:15 - 00:30': 532.0,
  '00:30 - 00:45': 436.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 376.0},
 '14545IB_P1': {'00:00 - 00:15': 464.0,
  '00:15 - 00:30': 524.0,
  '00:30 - 00:45': 448.0,
  '00:45 - 01:00': 400.0,
  '01:00 - 01:15': 384.0},
 '14545IB_P0': {'00:00 - 00:15': 468.0,
  '00:15 - 00:30': 516.0,
  '00:30 - 00:45': 444.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 380.0},
 '14544IB_P1': {'00:00 - 00:15': 440.0,
  '00:15 - 00:30': 516.0,
  '00:30 - 00:45': 440.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 380.0},
 '14544IB_P0': {'00:00 - 00:15': 444.0,
  '00:15 - 00:30': 512.0,
  '00:30 - 00:45': 444.0,
  '00:45 - 01:00': 392.0,
  '01:00 - 01:15': 364.0},
 '14543IB_P1': {'00:00 - 00:15': 456.0,
  '00:15 - 00:30': 524.0,
  '00:30 - 00:45': 440.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 364.0},
 '14543IB_P0': {'00:00 - 00:15': 452.0,
  '00:15 - 00:30': 528.0,
  '00:30 - 00:45': 444.0,
  '00:45 - 01:00': 400.0,
  '01:00 - 01:15': 368.0},
 '14542IB_P1': {'00:00 - 00:15': 444.0,
  '00:15 - 00:30': 516.0,
  '00:30 - 00:45': 432.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 368.0},
 '14542IB_P0': {'00:00 - 00:15': 444.0,
  '00:15 - 00:30': 528.0,
  '00:30 - 00:45': 428.0,
  '00:45 - 01:00': 396.0,
  '01:00 - 01:15': 356.0},
 '14540IB_P1': {'00:00 - 00:15': 384.0,
  '00:15 - 00:30': 412.0,
  '00:30 - 00:45': 352.0,
  '00:45 - 01:00': 340.0,
  '01:00 - 01:15': 300.0},
 '14540IB_P0': {'00:00 - 00:15': 384.0,
  '00:15 - 00:30': 408.0,
  '00:30 - 00:45': 348.0,
  '00:45 - 01:00': 332.0,
  '01:00 - 01:15': 304.0},
 '14537IB_P1': {'00:00 - 00:15': 420.0,
  '00:15 - 00:30': 420.0,
  '00:30 - 00:45': 340.0,
  '00:45 - 01:00': 330.0,
  '01:00 - 01:15': 300.0},
 '14537IB_P0': {'00:00 - 00:15': 530.0,
  '00:15 - 00:30': 565.0,
  '00:30 - 00:45': 455.0,
  '00:45 - 01:00': 445.0,
  '01:00 - 01:15': 420.0},
 '14536IB_P1': {'00:00 - 00:15': 296.0,
  '00:15 - 00:30': 260.0,
  '00:30 - 00:45': 300.0,
  '00:45 - 01:00': 212.0,
  '01:00 - 01:15': 260.0},
 '14536IB_P0': {'00:00 - 00:15': 304.0,
  '00:15 - 00:30': 256.0,
  '00:30 - 00:45': 290.0,
  '00:45 - 01:00': 208.0,
  '01:00 - 01:15': 256.0},
 '14405WB_P1': {'00:00 - 00:15': 504.0,
  '00:15 - 00:30': 520.0,
  '00:30 - 00:45': 456.0,
  '00:45 - 01:00': 428.0,
  '01:00 - 01:15': 376.0},
 '14405WB_P0': {'00:00 - 00:15': 504.0,
  '00:15 - 00:30': 524.0,
  '00:30 - 00:45': 448.0,
  '00:45 - 01:00': 420.0,
  '01:00 - 01:15': 376.0}}
                I don't think you can use plotly_express for your problem as x and y should be strings. Check the output of px.scatter?
px.scatter?
data_frame: A 'tidy' `pandas.DataFrame`
x: (string, name of column in `data_frame`) Values from this column are used to position marks along the x axis in cartesian coordinates.
y: (string, name of column in `data_frame`) Values from this column are used to position marks along the y axis in cartesian coordinates.
Given that installing plotly_express you get plotly too you can just use
import plotly.offline as py
import plotly.graph_objs as go
import pandas as pd
# here I'm using your df.head().to_dict() as dct
df = pd.DataFrame(dct)
traces = [go.Scatter(x=df.index,
                     y=df[col],
                     name=col)
          for col in df.columns]
py.iplot(traces)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With