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
-
Custom Date Attribute:
DataFrameobjects now include adateattribute, 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.
-
Custom String and HTML Representations:
- The
__str__method has been overridden to display thedatealongside 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.
- The
-
File I/O with Date Preservation:
to_csv,to_parquet,to_excel, andto_picklemethods automatically include thedateattribute as a new column,__date, before saving the data.- When reading files back into memory using
read_csv,read_parquet,read_excel, orread_pickle, the date is restored from the__datecolumn, reconstructing the DataFrame in its original state.
-
Intelligent Index Handling:
- The
_reconstructfunction handles unnamed columns in CSV and Excel files (e.g.,Unnamed: 0), commonly introduced by default index columns. - If
Unnamed: 0is detected as the first column, it is used as the index, and the column is subsequently removed, resulting in a cleaner DataFrame.
- The
Functions in pandasdate:
DataFrame: Extendspd.DataFrameto 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 thedateattribute 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
DataFramesubclass 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. readmethods 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50b966087e5198d1bcb533625fec0ae89f52319255c1b4cc934a2f6a94c6b8e0
|
|
| MD5 |
85da3772ec0ccde82b397cdaad811466
|
|
| BLAKE2b-256 |
d762d7cede5d64db493da5d42ac5c2cc905cbd3c61f9c79ddf1bd8ab11fec348
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
887c6746a50a9cb6b4744a27ae2fe4230069bbd3222974929e144cfaf49a8c6c
|
|
| MD5 |
b65c09bec879edf537dde8b4d6439ada
|
|
| BLAKE2b-256 |
c34a06408b74b1def909153bfba8959f555a38da4bd6d7c962a22b9c7eada522
|