Click here to Skip to main content
14,969,978 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys!

I'm converting JSON data into a pandas table, but I still need to convert datetime string to a float so that the mplfinance interpreter is able to read and plot the data. But there is an issue with one of the packages in the interpreter when trying to execute the code.

Does anyone know why the updated version of mpl_finance doesn't have this date2num package (as far as I know)? This code used to work on the previous version of mpl_finance, but for some reason I'm not able to use the 'date2num' package.

What can be an alternative way to make this work?

Code:

Python
import mplfinance as mpf

import datetime

from mplfinance import date2num

#Convert date string to date float

float_date = date2num(datetime.datetime.strptime(df['date'], '%Y-%m-%dT%H:%M:%S+%f'))

print(aapl_df)

mpf.plot(aapl_df)


What I have tried:

import mplfinance as mpf

import datetime

from mplfinance import date2num

#Convert date string to date float

float_date = date2num(datetime.datetime.strptime(df['date'], '%Y-%m-%dT%H:%M:%S+%f'))

print(aapl_df)

mpf.plot(aapl_df)

Error Message: cannot import name 'date2num' from 'mlpfinance'
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900