question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table function changing dates (-1) from Pandas DataFrame upon execution

See original GitHub issue

Hello,

I am using DataPane to create a simple report to track historical metric values, day over day. The data is being read in via Pandas excel function to a DataFrame and then I am creating a graph in plotly to visualize it. I am trying to leverage the table function in DataPane to also give the raw data along with the graph. I noticed that the dates are shifting with respect to the data. The first date in my file is September 1st, yet it is shifting everything back 1 day so that the start date of the RAW Data table output is August 31st.

Does anyone see anything that I can do, or is this a potential bug? I know i could probably convert the dates to a string, but it seems like i shouldn’t have to do that if the table function is going to assume data types.

image

DataPaneTest.xlsx

` import pandas as pd import datapane as dp import plotly.graph_objects as go import plotly.io as pio

HistoricalData = pd.read_excel(r’mypath\DataPaneTest.xlsx’) HistoricalData[‘DataDate’] = HistoricalData[‘DataDate’].astype(‘datetime64[ns]’)

pio.templates.default = “plotly_dark”

fig = go.Figure() fig.add_trace(go.Scatter(x=HistoricalData[‘DataDate’], y=HistoricalData[‘col1’], mode=‘lines+markers’, name=‘t1’)) fig.add_trace(go.Scatter(x=HistoricalData[‘DataDate’], y=HistoricalData[‘col2’], mode=‘lines+markers’, name=‘t2’)) fig.add_trace(go.Scatter(x=HistoricalData[‘DataDate’], y=HistoricalData[‘col3’], mode=‘lines+markers’, name=‘t3’)) fig.add_trace(go.Scatter(x=HistoricalData[‘DataDate’], y=HistoricalData[‘col4’], mode=‘lines+markers’, name=‘t4’)) fig.update_layout( title_text=‘t0’,title_x=0.5)

dp.Report( dp.Markdown(“# Stuff”), dp.Markdown(" “), dp.Plot(fig), dp.Markdown(” “), dp.Markdown(”## RAW Data"), dp.Table(HistoricalData)

).save(path=r’mypath\DataPaneTest.html’, open=True) `

_Originally posted by @JCP281 in https://github.com/datapane/datapane/discussions/39_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
JCP281commented, Nov 19, 2020

Awesome. Thanks @Buroni and @mands.

You both rock!

2reactions
mandscommented, Nov 12, 2020

Thanks for raising this - we’re planning on digging into the date handling and the table component as a whole next week, I think it may be related to some JS timezone handing in our table report code but we’ll fix it very shortly as a few users have had issues with dates.

In the meantime, I can suggest converting to a string until the fix comes out - so sorry for the inconvenience!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pandas Change String to Date in DataFrame
Format – You can change the pandas DataFrame column type from string to date format by using pandas. to_datetime() and DataFrame. astype() ...
Read more >
how to convert a panda column into big query table date format
PublishDate= 2018-08-31 I used panda to_gbq() function to dump data into a bigquery table. Before dumping data, I make sure that the format...
Read more >
Processing time with Pandas DataFrame - GeeksforGeeks
Let's discuss all the different ways to process date and time with Pandas dataframe. Divide date and time into multiple features:
Read more >
Essential basic functionality — pandas 1.5.2 documentation
Using these functions, you can use to either match on the index or columns via the axis keyword: >>> In [18]: df =...
Read more >
Windowing operations — pandas 1.5.2 documentation
Overview# · method='table' option in the constructor which performs the windowing operation over an entire DataFrame instead of a single column or row...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found