Skip to content

TypeError: Expect data.index as DatetimeIndex #89

Description

@0xarbs

how to deal with the error and mpf.plot(pdata) didn't work.
thx

import requests
import json
import pandas as pd
import mplfinance as mpf
import matplotlib.pyplot as plt

url = "https://api.huobi.pro/market/history/kline?period=5min&size=3&symbol=btcusdt"
r = requests.get(url)
data = json.loads(r.content)['data']
print("data:", data)
pdata = pd.DataFrame(data)
pdata.index.name = 'id'
pdata = pdata[['id', 'open', 'close', 'high', 'low', 'vol', 'amount', 'count']]
pdata['id'] = pd.to_datetime(pdata['id'], unit='s')
mpf.plot(pdata)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions