Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.astype("int") or .astype(int)? Any differences between with and without quote/double?

Tags:

python

pandas

I have a DataFrame and one of its column consist of float type objects. I want to convert to int. As I tried, both .astype("int") and astype(int) methods work. I just wonder whether there is/are any difference(s)?

like image 286
Natig Aliyev Avatar asked Jan 22 '17 14:01

Natig Aliyev


1 Answers

AFAIK there is no major difference...

.astype(dtype) should accept everything what is accepted by numpy.dtype().

Internally it does this:

dtype = np.dtype(dtype)
like image 193
MaxU - stop WAR against UA Avatar answered Nov 09 '22 16:11

MaxU - stop WAR against UA