1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Plot with date on x, time of day on y, and value

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    Trying to do a three-variable plot in matplotlib with a pandas data frame arranged as follows (third column value would be a color, green to red/low to high):

    Date Time Value
    2023-11-01 11:22:34 59.0
    2023-11-01 11:25:26 65.0
    .
    .
    .


    I cannot get this thing to plot without an error about a time value has to be a float, etc.

    x = pandas.read_xml('/Users/steven/Downloads/apple_health_export/export.xml', xpath='//Record', attrs_only=True,parse_dates=["creationDate","startDate","endDate"])
    x.value=pandas.to_numeric(x.value,errors='coerce')
    x = x[x.value.notnull()]
    data = x[x.type == 'HKQuantityTypeIdentifierHeartRate']
    data['Date']=[datetime.datetime.date(d) for d in data['endDate']]
    data['Time']=[datetime.datetime.time(d) for d in data['endDate']]

    Continue reading...

Compartilhe esta Página