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

The datetime transformers don't give me back the same dtype sometimes #657

Closed
npatki opened this issue Jun 22, 2023 · 0 comments · Fixed by #661
Closed

The datetime transformers don't give me back the same dtype sometimes #657

npatki opened this issue Jun 22, 2023 · 0 comments · Fixed by #661
Assignees
Labels
bug Something isn't working
Milestone

Comments

@npatki
Copy link
Contributor

npatki commented Jun 22, 2023

Environment Details

  • RDT version: 1.5.0
  • Python version: Any
  • Operating System: Any

Error Description

In some rare cases, I may have a datetime column that is represented as a float or integer dtype. When this happens, I will always have a datetime_format string that specifies how to read this.

Example:

  • A column of all nan values
  • A column with format '%Y%m%d' such as [20120212, 20100321, 20091102, ...]

If this happens, then the output dtype (on the reverse_transform) is not the same dtype as the input.

Proposed Fix

On the fit:

  • Store the original _dtype of the input column

On the transform:

  1. Convert it to a string (astype("string") to make sure the NaNs are properly converted)
  2. Parse to pd.datetime to using the provided datetime_format
  3. Convert from pd.datetime -> unix timestamp

On the reverse_transform:

  1. Convert from unix timestamp -> pd.datetime
  2. Convert it to a string (using datetime_format)
  3. Convert back to the original _dtype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants