Skip to content

write_sav() and datetime gives wrong format #69

@josmos

Description

@josmos

According to the Readme datetime, date, time should be converted to numeric with datetime/date/time formatting.

I am converting strings to datetime64[ns] dtype with:

df[field_name] = pd.to_datetime(df[field_name], errors="coerce")

or

df[field_name] = pd.to_datetime(df[field_name], format='%H:%M', errors="coerce")

for time, respectively.

The resulting sav variable has numeric type with F8.2 format

How can I convert it to SPSS DATE or TIME format?
Is this a bug? In case I am getting something wrong, please explain how to get the right format.

Thanks
Josef

Setup Information:

i installed pyreadstat via pipenv

INSTALLED VERSIONS

commit : d9fff2792bf16178d4e450fe7384244e50635733
python : 3.7.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-42-generic
Version : #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.1.0
numpy : 1.19.1
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions