Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot access columns populated with Date objects #509

Closed
nholmes3 opened this issue Oct 4, 2022 · 3 comments · Fixed by #511
Closed

Cannot access columns populated with Date objects #509

nholmes3 opened this issue Oct 4, 2022 · 3 comments · Fixed by #511
Assignees
Labels
enhancement New feature or request

Comments

@nholmes3
Copy link

nholmes3 commented Oct 4, 2022

Describe the bug
When trying to access a column that is populated with Date objects, the following error is thrown

File format not supported!

To Reproduce
Steps to reproduce the behavior:

const df = new dfd.DataFrame([{'foo': 'bar'}]);
df.addColumn('dateColumn', [new Date()], {inplace: true});
const dateColumn = df.column('dateColumn');

This is a result of the data not passing any of the conditionals in the NDframe constructor

My suggestion is to update either of these conditions to include a check for Date objects:
https://github.com/javascriptdata/danfojs/blob/dev/src/danfojs-base/core/generic.ts#L79
https://github.com/javascriptdata/danfojs/blob/dev/src/danfojs-base/core/generic.ts#L83

Expected behavior
The column should be returned correctly without error

Desktop (please complete the following information):

  • OS: Node 16 Docker Image (FROM node:16)
  • Version 1.1.1
@jaydeep-work
Copy link

jaydeep-work commented Oct 10, 2022

hi, you can try :
const dateColumn = df.column('dateColumn').$data;

@nholmes3
Copy link
Author

hi, you can try : const dateColumn = df.column('dateColumn').$data;

Hi @jaydeep-work, thank you for posting your workaround! I am currently converting the dates to strings before adding them to the DF, but both of these workarounds are less desirable than danfo being able to handle Date objects in the first place.

@risenW risenW self-assigned this Oct 12, 2022
@risenW
Copy link
Member

risenW commented Oct 12, 2022

I've been working on adding default support for Datetime columns. This will get pushed in the new release.

@risenW risenW added the enhancement New feature or request label Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants