simfin icon indicating copy to clipboard operation
simfin copied to clipboard

Deprecation warning for `date_parser` in Pandas `read_csv` function.

Open ghost opened this issue 2 years ago • 1 comments

I currently encounter a deprecation warning when using the pd.read_csv function with date_parser.

FutureWarning: The argument 'date_parser' is deprecated and will be removed in a future version. Please use 'date_format' instead, or read your data in as 'object' dtype and then call 'to_datetime'.

this is supported by the Pandas documentation, which states:

Deprecated since version 2.0.0: Use date_format instead, or read in as object and then apply to_datetime() as-needed.

this warning was obtained whilst running the following line of code:

https://github.com/SimFin/simfin/blob/413ec1691b78da96ef834890a0aa543c3694d6d8/simfin/load.py#L154-L155

as per the warning and the supporting Pandas documentation, I'm recommending that we read data in as object dtype and then call pd.to_datetime() to convert each of these columns from object dtype to datetime64[ns] dtype.

I've submitted a pull request here.

ty

ghost avatar Sep 23 '23 08:09 ghost

I'm getting the same warning: "/opt/anaconda3/lib/python3.12/site-packages/simfin/load.py:154: FutureWarning: The argument 'date_parser' is deprecated and will be removed in a future version. Please use 'date_format' instead, or read your data in as 'object' dtype and then call 'to_datetime'. df = pd.read_csv(path, sep=';', header=0,"

bnsheehy avatar May 14 '25 12:05 bnsheehy