Skip to main content

A pandas DataFrame extension with date tracking

Project description

pandasdate - Version 1.0.2

This package, pandasdate, is a custom wrapper around pandas.DataFrame that introduces a date attribute to track a specified date associated with the dataset. The DataFrame subclass is designed to work seamlessly with common data formats while preserving metadata about the date, making it particularly useful for applications that require associating data with a specific timestamp.

Access git-repository via: https://github.com/EshanJayasundara/pandasdate

Key Features

  1. Custom Date Attribute:

    • DataFrame objects now include a date attribute, which defaults to September 19, 2000, but can be specified upon instantiation.
    • This attribute provides a reference date to keep metadata within the data frame object, enhancing temporal tracking.
  2. Custom String and HTML Representations:

    • The __str__ method has been overridden to display the date alongside the data when printed in the terminal.
    • _repr_html_ provides a similar enhancement for Jupyter Notebook environments, appending the date for a more informative display.
  3. File I/O with Date Preservation:

    • to_csv, to_parquet, to_excel, and to_pickle methods automatically include the date attribute as a new column, __date, before saving the data.
    • When reading files back into memory using read_csv, read_parquet, read_excel, or read_pickle, the date is restored from the __date column, reconstructing the DataFrame in its original state.
  4. Intelligent Index Handling:

    • The _reconstruct function handles unnamed columns in CSV and Excel files (e.g., Unnamed: 0), commonly introduced by default index columns.
    • If Unnamed: 0 is detected as the first column, it is used as the index, and the column is subsequently removed, resulting in a cleaner DataFrame.

Functions in pandasdate:

  • DataFrame: Extends pd.DataFrame to include date tracking, custom display, and enhanced I/O.
  • _reconstruct: Reconstructs DataFrames by restoring the date and intelligently handling unnamed index columns.
  • read_csv, read_parquet, read_excel, read_pickle: Read functions that reconstruct the DataFrame with the date attribute from saved files.

Example Usage

import pandasdate as pd_date

# Create a DataFrame with a custom date
df = pd_date.DataFrame({'A': [1, 2, 3]}, year=2024, month=11, day=9)
print(df)

# Save the DataFrame with date information
df.to_csv('data.csv')
df.to_parquet('data.parquet')

# Read back into memory, with date automatically restored
new_df = pd_date.read_csv('data.csv')
print(new_df.date)  # Outputs: 2024-11-09

Release Notes for 1.0.2

  • Initial release of pandasdate.
  • Introduces DataFrame subclass with date attribute.
  • Custom __str__ and _repr_html_ for enhanced displays.
  • File I/O methods (to_csv, to_parquet, to_excel, to_pickle) that preserve the date.
  • read methods for all major file formats, reconstructing DataFrames with original date information.

This release lays a robust foundation for future enhancements, including potentially adding custom date operations and compatibility with additional file formats.

Release 1.0.0 and release 1.0.1 was removed due to some inconsistancies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandasdate-1.0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

pandasdate-1.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pandasdate-1.0.2.tar.gz.

File metadata

  • Download URL: pandasdate-1.0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pandasdate-1.0.2.tar.gz
Algorithm Hash digest
SHA256 50b966087e5198d1bcb533625fec0ae89f52319255c1b4cc934a2f6a94c6b8e0
MD5 85da3772ec0ccde82b397cdaad811466
BLAKE2b-256 d762d7cede5d64db493da5d42ac5c2cc905cbd3c61f9c79ddf1bd8ab11fec348

See more details on using hashes here.

File details

Details for the file pandasdate-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pandasdate-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pandasdate-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 887c6746a50a9cb6b4744a27ae2fe4230069bbd3222974929e144cfaf49a8c6c
MD5 b65c09bec879edf537dde8b4d6439ada
BLAKE2b-256 c34a06408b74b1def909153bfba8959f555a38da4bd6d7c962a22b9c7eada522

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page