'NaTType does not support isocalendar (just on one particular machine)
I have a few pythons scripts that run fine, except on one laptop, where they throw this error NaTType does not support isocalendar. On other laptops they run fine, same version of Python & Pandas*, uninstalled and re-installed Python but still the same.
*Correction: script runs fine on python 3.9.7 but not on 3.10
Any suggestion what to look at next? Thanks!
Here a snippet of one of the scripts that run fine on other machines, with the same underlying data:
145 # create list of lists of values
146 pm01_emea = [pm01_emea.columns.tolist()] + pm01_emea.values.tolist()
147
148 # write the headers and data starting in row 1 (index 0)
149 row = 0
150 for project in (pm01_emea):
151 worksheet0.write_row(row, 0, project)
152 row +=1
Here the error it is throwing:
Traceback (most recent call last):
File "C:\GitHub\pm01\pm01.py", line 151, in <module>
worksheet0.write_row(row, 0, project)
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\worksheet.py", line 85, in
cell_wrapper
return method(self, *args, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\worksheet.py", line 1370, in write_row
error = self._write(row, col, token, cell_format)
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\worksheet.py", line 508, in _write
return self._write_datetime(row, col, *args)
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\worksheet.py", line 1019, in _write_datetime
number = self._convert_date_time(date)
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\worksheet.py", line 4320, in _convert_date_time
return datetime_to_excel_datetime(dt_obj,
File "C:\Users\username\AppData\Local\Programs\Python\Python310\lib\site-packages\xlsxwriter\utility.py", line 702, in datetime_to_excel_datetime
and dt_obj.isocalendar() == (1900, 1, 1)):
File "pandas\_libs\tslibs\nattype.pyx", line 75, in pandas._libs.tslibs.nattype._make_error_func.f
ValueError: NaTType does not support isocalendar
PS C:\GitHub\pm01>
Solution 1:[1]
No solution found other than to uninstall Python 3.10.2 and reinstall 3.9.7 from scratch. Didn't want to go into venv but needed a fast solution.
Solution 2:[2]
I have faced same issue while using Python version 3.9.6 However, after manually updating numpy and pandas I don't observe the issue anymore:
pip freeze | grep -e pandas -e numpy
numpy==1.22.2
pandas==1.4.1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jondalar |
| Solution 2 | Alexander Atanasov |
