Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Format SAS DATE
#1
Having a issue locating the proper format.

for k, v in ds.items():
                v.label = k.title()
                print(v.dtype )
                if v.dtype == 'object':
                    v.format = '$CHAR20.'
                elif v.dtype == 'datetime64[ns]':
                    v.format = '$DATETIME.'                
                else:
                    v.format = '10.2'
Error:
493 2019-04-02 09:47:44.433262100 Name: dtsub, Length: 494, dtype: datetime64[ns] object int64 object int64 object object int64 object object int64 object int64 object int64 object object int64 object int64 object int64 object datetime64[ns] Traceback (most recent call last): File "c:\Users\Test Files\NewXport.py", line 98, in <module> v.format = '$DATETIME.' File "C:\Users\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py", line 5500, in __setattr__ return object.__setattr__(self, name, value) File "C:\Users\Local\Programs\Python\Python310\lib\site-packages\xport\__init__.py", line 398, in format self._format = Format.from_spec(value) File "C:\Users\Local\Programs\Python\Python310\lib\site-packages\xport\__init__.py", line 264, in from_spec return super().from_spec(spec=spec, justify=justify) File "C:\Users\Local\Programs\Python\Python310\lib\site-packages\xport\__init__.py", line 162, in from_spec raise ValueError(f'Invalid informat {spec}') ValueError: Invalid informat $DATETIME.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare current date on calendar with date format file name Fioravanti 1 243 Mar-26-2024, 08:23 AM
Last Post: Pedroski55
  Python date format changes to date & time 1418 4 618 Jan-20-2024, 04:45 AM
Last Post: 1418
  Modifying a date format jehoshua 17 3,006 Oct-29-2022, 08:44 PM
Last Post: jehoshua
  Date format error getting weekday value Aggie64 2 1,427 May-29-2022, 07:04 PM
Last Post: Aggie64
  Convert Date to another format lonesoac0 2 1,678 Mar-17-2022, 11:26 AM
Last Post: DeaD_EyE
  How can I compare 2 format of date? korenron 4 1,532 Dec-21-2021, 12:40 PM
Last Post: korenron
  Date format and past date check function Turtle 5 4,273 Oct-22-2021, 09:45 PM
Last Post: deanhystad
  Print first day of the week as string in date format MyerzzD 2 2,027 Sep-29-2021, 06:43 AM
Last Post: MyerzzD
  String to Date format SAF 2 2,473 Apr-06-2021, 02:09 PM
Last Post: snippsat
  How to add previous date infront of every unique customer id's invoice date ur_enegmatic 1 2,241 Feb-06-2021, 10:48 PM
Last Post: eddywinch82

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020