GithubHelp home page GithubHelp logo

Comments (12)

WillAyd avatar WillAyd commented on May 19, 2024

Thanks for the report. This is “by design” in today’s world because there isnt a first class dtype in pandas for dates.

Your workaround is the suggested approach, though if you really want date and not date time in the extract it falls short. I think could use a keyword argument that allows you to explicitly store date time dtypes as dates - interested in trying a PR for that?

from pantab.

mhadi813 avatar mhadi813 commented on May 19, 2024

Thanks will, i'll make a PR.

from pantab.

mhadi813 avatar mhadi813 commented on May 19, 2024

I'm trying to make a PR for kwargs for casting datetime.date to pd.datetime. Can you grant me permission? Thanks

def frame_to_hyper(
df: pd.DataFrame,
database: Union[str, pathlib.Path],
*,
table: pantab_types.TableType,
table_mode: str = "w",
**kwargs: Union[str, list]
) -> None:
"""See api.rst for documentation"""
if 'date_column' in kwargs:
date_column = kwargs.get('date_column')
if isinstance(date_column, list):
for col in date_column:
df[col] = pd.to_datetime(df[col])
elif isinstance(date_column, str):
df[date_column] = pd.to_datetime(df[date_column])

from pantab.

WillAyd avatar WillAyd commented on May 19, 2024

from pantab.

WillAyd avatar WillAyd commented on May 19, 2024

So there is a discussion of adding this as a type upstream in pandas:

pandas-dev/pandas#32473

I think any work we do here would have to wait on that, so let's see if that gets traction

from pantab.

joshuataylor avatar joshuataylor commented on May 19, 2024

The date field seems to have stalled in pandas, can this be considered again?

We have a fair few dates in our project, and would love to use pantab for this.

from pantab.

WillAyd avatar WillAyd commented on May 19, 2024

@joshuataylor have you looked at hyperarrow? It is a similar tool but with arrow as a back end you get first class DATE support

https://hyperarrow.readthedocs.io/en/latest/

from pantab.

joshuataylor avatar joshuataylor commented on May 19, 2024

I didn't know that library existed, awesome work 😍 . Will give it a go.

from pantab.

jstrauss18 avatar jstrauss18 commented on May 19, 2024

Is this still open? Running into this issue right now using pandas.

TypeError: Invalid value "datetime.date(2023, 10, 5)" found (row 0 column 5)

from pantab.

WillAyd avatar WillAyd commented on May 19, 2024

@jstrauss18 your column dtype is likely object. If you want to write time stamps make sure you use a datetime dtype column. Pandas does not natively support plain DATE types (pyarrow does, but pantab currently does not leverage pyarrow types)

from pantab.

jstrauss18 avatar jstrauss18 commented on May 19, 2024

Not sure what to do. I'm using databricks delta sharing to load data frame and I don't name the columns.

df

from pantab.

WillAyd avatar WillAyd commented on May 19, 2024

Sorry I'm not familiar with databricks so can't give specific advice. You might want to try StackOverflow for something more tailored. Most I/O methods in pandas provide a parse_dates= argument that you can use when inferencing is not correct, although there may be something more foundational to be fixed with your code

As a hack you could try df.iloc[:, 5] = pd.to_datetime(df.iloc[:, 5]) since the traceback says its the fifth column where you are having an issue. But beyond that I would try StackOverflow or a Databricks support forum

from pantab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.