-   Notifications  You must be signed in to change notification settings 
- Fork 15
Closed
Description
Problem
 Creating a Series object using the from_pandas method raises a HighchartsValueError if the column is of type datetime. The problem started appearing after upgrading highcharts_core to v1.4.0.
Imagine a DataFrame df with the following data:
 Timestamp Value 0 2023-10-01 10 1 2023-10-02 20 2 2023-10-03 30 3 2023-10-04 40 4 2023-10-05 50 When creating a LineSeries object as shown
from highcharts_core.options.series.area import LineSeries LineSeries.from_pandas(df, property_map={"x": "timestamp", "y": "value"})The following error is raised
Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/highcharts_core/options/series/data/collections.py", line 274, in __setattr__ setattr(data_points[index], name, value[index]) File "/usr/local/lib/python3.10/site-packages/highcharts_core/options/series/data/cartesian.py", line 134, in x value = validators.string(value) File "/usr/local/lib/python3.10/site-packages/validator_collection/_decorators.py", line 51, in func_wrapper return func(*args, **updated_kwargs) File "/usr/local/lib/python3.10/site-packages/validator_collection/validators.py", line 241, in string raise errors.CannotCoerceError('value (%s) was not coerced to a string' % value) validator_collection.errors.CannotCoerceError: value (2023-10-01T00:00:00.000000000) was not coerced to a string During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.10/site-packages/highcharts_core/options/series/base.py", line 2108, in from_pandas series_list = cls._from_pandas_multi_map(df, File "/usr/local/lib/python3.10/site-packages/highcharts_core/options/series/base.py", line 1859, in _from_pandas_multi_map setattr(collection_instance, key, prop_array) File "/usr/local/lib/python3.10/site-packages/highcharts_core/options/series/data/collections.py", line 285, in __setattr__ raise errors.HighchartsValueError( highcharts_core.errors.HighchartsValueError: Unable to set x to 2023-10-01T00:00:00.000000000. If using a helper method, this is likely due to mismatched columns. Please review your input data. To Repoduce run the following code
import pandas as pd import datetime as dt from highcharts_core.options.series.area import LineSeries # Generate timestamps for the first 5 days of October 2023 start_date = dt.datetime(2023, 10, 1) end_date = dt.datetime(2023, 10, 5) date_range = [start_date + dt.timedelta(days=i) for i in range(5)] # Create a list of values values = [10, 20, 30, 40, 50] # Create a DataFrame df = pd.DataFrame({'Timestamp': date_range, 'Value': values}) LineSeries.from_pandas(df, property_map={"x": "Timestamp", "y": "Value"})Environment:
- OS: Linux
- Python Version: 3.10.8
- Highcharts Python Version: 1.4.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working