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

Sudden switch small Number to DateTime. #1270

Open
wiluite opened this issue Dec 13, 2024 · 2 comments
Open

Sudden switch small Number to DateTime. #1270

wiluite opened this issue Dec 13, 2024 · 2 comments
Labels

Comments

@wiluite
Copy link

wiluite commented Dec 13, 2024

Hello,

The csvkit version is 1.5.0

echo 13/12/2024, 5.5 | csvstat -H

  1. "a"

    Type of data: Text
    Contains null values: False
    Non-null values: 1
    Unique values: 1
    Longest value: 10 characters
    Most common values: 13/12/2024 (1x)

  2. "b"

    Type of data: Number
    Contains null values: False
    Non-null values: 1
    Unique values: 1
    Smallest value: 5.5
    Largest value: 5.5
    Sum: 5.5
    Mean: 5.5
    Median: 5.5
    Most decimal places: 1
    Most common values: 5.5 (1x)

Now I want to see Dates in the 1st column:

echo 13/12/2024, 5.5 | csvstat -H --date-format "%d/%m/%Y"

  1. "a"

     Type of data:          Date
     Contains null values:  False
     Non-null values:       1
     Unique values:         1
     Smallest value:        2024-12-13
     Largest value:         2024-12-13
     Most common values:    2024-12-13 (1x)
    
  2. "b"

    Type of data: DateTime
    Contains null values: False
    Non-null values: 1
    Unique values: 1
    Smallest value: 2025-05-05 00:00:00
    Largest value: 2025-05-05 00:00:00
    Most common values: 2025-05-05 00:00:00 (1x)

But now, I suddenly see a datetime in the 2nd column.
(If, however, I provide say 5.50 instead 5.5, or a larger number, than that's still number.)

Should I upgrade to the recent version?
Thanks.

@jpmckinney
Copy link
Member

I recommend upgrading both csvkit and agate (a dependency) to their latest versions and retrying.

@wiluite
Copy link
Author

wiluite commented Dec 13, 2024

Done:

wiluite@slax:~$ pip show agate
Name: agate
Version: 1.12.0
Summary: A data analysis library that is optimized for humans instead of machines.
Home-page: https://agate.readthedocs.org/
Author: Christopher Groskopf
Author-email: chrisgroskopf@gmail.com
License: MIT
Location: /usr/local/lib/python3.9/dist-packages
Requires: parsedatetime, Babel, leather, pytimeparse, python-slugify, isodate
Required-by: csvkit, agate-sql, agate-excel, agate-dbf

wiluite@slax:~$ pip show csvkit
Name: csvkit
Version: 2.0.1
Summary: A suite of command-line tools for working with CSV, the king of tabular file formats.
Home-page: https://github.com/wireservice/csvkit
Author: Christopher Groskopf and James McKinney
Author-email: chrisgroskopf@gmail.com
License: MIT
Location: /usr/local/lib/python3.9/dist-packages
Requires: agate-dbf, sqlalchemy, agate, importlib-metadata, xlrd, agate-excel, agate-sql, openpyxl
Required-by:

wiluite@slax:~$ echo 13/12/2024, 5.5 | csvstat -H --date-format "%d/%m/%Y"

  1. "a"

    Type of data: Date
    Contains null values: False
    Non-null values: 1
    Unique values: 1
    Smallest value: 2024-12-13
    Largest value: 2024-12-13
    Most common values: 2024-12-13 (1x)

  2. "b"

    Type of data: DateTime
    Contains null values: False
    Non-null values: 1
    Unique values: 1
    Smallest value: 2025-05-05 00:00:00
    Largest value: 2025-05-05 00:00:00
    Most common values: 2025-05-05 00:00:00 (1x)

Row count: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants