Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cannot astype a datetimelike from [datetime64[ns]] to [int32] #31

Open
Ariel-55 opened this issue Dec 27, 2022 · 0 comments
Open

Comments

@Ariel-55
Copy link

Good morning,

I get this error when I run the code. I used this command to run it "python main.py --do_train --mlm --field_ce --lm_type bert --field_hs 64 --data_type 'card' --output_dir 'output_dir_card'". I am suing visual studio code to run the code.

The following is the complete error:

File "main.py", line 152, in
main(opts)
File "main.py", line 48, in main
skip_user=args.skip_user)
File "C:\Users\Ariel\Documents\HSE\3rd Term\HNCC\TabFormer-main\dataset\card.py", line 66, in init
self.encode_data()
File "C:\Users\Ariel\Documents\HSE\3rd Term\HNCC\TabFormer-main\dataset\card.py", line 309, in encode_data
timestamp = self.timeEncoder(data[['Year', 'Month', 'Day', 'Time']])
File "C:\Users\Ariel\Documents\HSE\3rd Term\HNCC\TabFormer-main\dataset\card.py", line 104, in timeEncoder
int)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\generic.py", line 5815, in astype
new_data = self._mgr.astype(dtype=dtype, copy=copy, errors=errors)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\internals\managers.py", line 418, in astype
return self.apply("astype", dtype=dtype, copy=copy, errors=errors)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\internals\managers.py", line 327, in apply
applied = getattr(b, f)(**kwargs)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\internals\blocks.py", line 591, in astype
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\dtypes\cast.py", line 1309, in astype_array_safe
new_values = astype_array(values, dtype, copy=copy)
File "C:\Users\Ariel\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\dtypes\cast.py", line 1242, in astype_array
raise TypeError(msg)
TypeError: cannot astype a datetimelike from [datetime64[ns]] to [int32]

I am using Visual studio code to run the code. I am using python version 3.7 as you mentioned and the libraries you mentioned. Seems there is a problem in the line 48 and 152 of the main.py file. I will be really grateful if you can tell me how to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant