Python & Pandas - dp.Series difference between int32 and int64

I am starting to learn python, numpy and panda, and I have a basic question about sizes.

Refer to the following code blocks:

1. Length: 6, dtype: int64

# create a Series from a dict
pd.Series({key: value for key, value in zip('abcdef', range(6))})

against.

2. Length: 6, dtype: int32

# but why does this generate a smaller integer size???
pd.Series(range(6), index=list('abcdef'))

Question So I think that when you put a list, a numpy array, a dictionary, etc. In pd.Series you will get int64, but when you put only range (6) in pd.Series you will get int32. Can someone please make this a little understandable to me?

Sorry for the simplest question.

@Edit: I am using Pandas version 0.20.1 and Numpy 1.12.1

+4
source share
1 answer

, dict , dtype int64, range, trvially int32:

In[57]:
np.array(range(6)).dtype

Out[57]: dtype('int32')

, pandas series dtype , - , numpy, numpy , int32

, numpy , , pandas. python 3.6, numpy 1.12.1 pandas 0.20.3, . 64- Windows 7

@jeremycg pandas 0.19.2 numpy 1.11.2 , @coldspeed numpy 1.13.1 int64.

, dtype , numpy.

, - , , range .

subarr = np.array(arr, dtype=object, copy=copy)

numpy , C Long 32-. . : numpy dtype int32 Windows 10 64-

+4

Source: https://habr.com/ru/post/1685749/


All Articles