How do i get datetime into a tableau extract with pantab

0 votes

0

I have this code:

import pantab
import pandas as pd
import datetime
df = pd.DataFrame([
    [datetime.date(2018,2,20), 4],
    [datetime.date(2018,2,20), 4],
], columns=["date", "num_of_legs"])

pantab.frame_to_hyper(df, "example.hyper", table="animals")

which is causing this error:

TypeError: Invalid value "datetime.date(2018, 2, 20)" found (row 0 column 0)

How can I fix this?

Mar 10 in Tableau by Neha
• 8,560 points
47 views

1 answer to this question.

0 votes

Panda dtypes handle dates and strings as objects, thus you must know which columns are datetime columns. There's a universe where data scientists don't give a damn about dates, but evidently not mine. Anyway, here's the workaround till Pandas implements the date dtype:

[https://github.com/innobi/pantab/issues/100][1]

And just to reduce it down to do what I did:

def createHyper(xlsx, filename, tablename):
    for name in xlsx.columns:
        if 'date' in name.lower():
            xlsx[name] = pd.to_datetime(xlsx[name],errors='coerce',utc=True)
    pantab.frame_to_hyper(xlsx,filename,table=tablename)
    return open(filename, 'rb')

errors = 'coerce' makes it so you can have dates like 1/1/3000 which is handy in a world of scd2 tables utc = True was necessary for me because my dates were timezone sensitive, yours may not be.

answered Mar 14 by Vaani
• 7,020 points

Related Questions In Tableau

0 votes
1 answer

How to get multiple Sets of Measure Names with different Filters on a single sheet in Tableau?

The easiest solution to your query is: 1) ...READ MORE

answered Aug 23, 2018 in Tableau by Naruto
• 710 points
11,318 views
0 votes
1 answer
0 votes
0 answers

How can I convert a dimension into a measure in Tableau

I'd like to ask a technical question ...READ MORE

Mar 31 in Tableau by Vaani
• 7,020 points
56 views
0 votes
1 answer
0 votes
0 answers

Using Python and Tableau in conjunction with one another

Is it possible to mix Python visualisations ...READ MORE

Feb 28 in Tableau by Vaani
• 7,020 points
62 views
0 votes
0 answers

Tableau Desktop Inside Tableau Server

Is there an executable for Tableau Desktop ...READ MORE

Feb 28 in Tableau by Vaani
• 7,020 points
73 views
0 votes
0 answers

Tableau Map view Continent List

I've been attempting to tidy up my ...READ MORE

Feb 28 in Tableau by Vaani
• 7,020 points
52 views
0 votes
0 answers

Downloading tableau workbook from tableau server with data

I'm brand new to tableau server. I ...READ MORE

Feb 28 in Tableau by Vaani
• 7,020 points
82 views
0 votes
1 answer

Tableau: How to create a filter based of 3 different columns?

The case you're using for filters is ...READ MORE

answered Mar 16 in Tableau by Vaani
• 7,020 points
389 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP