CermakM / jupyter-datatables

Jupyter Notebook extension leveraging pandas DataFrames by integrating DataTables and ChartJS.
MIT License
238 stars 27 forks source link

graphs don't automatically change to line-graphs when index is a datetime object #19

Closed 4n4nd closed 5 years ago

4n4nd commented 5 years ago

Describe the bug graphs don't automatically change to line-graphs when index is a datetime object

To Reproduce Steps to reproduce the behavior:

Run the following code in a notebook cell

import pandas as pd
import datetime
# sample time-series data
my_data = [[datetime.datetime(2019, 8, 12, 18, 22, 10, 542999), 8.55206], [datetime.datetime(2019, 8, 12, 18, 23, 10, 542999), 8.552038], [datetime.datetime(2019, 8, 12, 18, 24, 10, 542999), 8.552016], [datetime.datetime(2019, 8, 12, 18, 25, 10, 542999), 8.551991], [datetime.datetime(2019, 8, 12, 18, 26, 10, 542999), 8.551966], [datetime.datetime(2019, 8, 12, 18, 27, 10, 543999), 8.551938], [datetime.datetime(2019, 8, 12, 18, 28, 10, 542999), 8.551909], [datetime.datetime(2019, 8, 12, 18, 29, 10, 542999), 8.551879], [datetime.datetime(2019, 8, 12, 18, 30, 10, 542999), 8.551847]]
print(my_data)

# create dataframe with datetime index
my_df = pd.DataFrame(my_data, columns=["ds","y"]).set_index("ds")
my_df

Expected behavior The plotted graphs to be line graphs instead of bar graphs

Version info: jupyter_datatables.__version__=0.3.1

CermakM commented 5 years ago

Hello and thank you for using the extension!

Care to elaborate why do you think this is a bug? From my perspective, this is the expected behaviour. The decision about the chart type is not made based on the index, but with regards to the dtype of the data column. Since you have a numerical column, it chooses the histogram by default.

Consider if you had for example strings or another kind of object which could not be turned into points ... then the line chart being the default for the datetime index would not make sense.

Cheers, Marek

4n4nd commented 5 years ago

Oh I am sorry, I thought that's what you said during your presentation. I am probably mistaken then.

Thanks 👍