I do not know whether to call it a small matter but it has been puzzling me. numpy.dtype prints differently formatted outputs, one without print statement and one with print statement. Here is an example:
train = pd.read_csv("train.csv")
In [10]: train.dtypes
Out[10]:
first_active_month object
card_id object
feature_1 int64
feature_2 int64
feature_3 int64
target float64
dtype: object
In [5]: train['card_id'].dtypes
Out[5]: dtype('O')
In [11]: print(train['card_id'].dtypes)
object
Kindly see the output of last two commands. When printed without using the 'print' statement, output is 'dtype('O')' and when printed with 'print' statement, the output is 'object'.
I have read numpy.dtype manual but could not find the reasons for these two different output formats. Also, the following works:
In [16]: train['card_id'].dtypes in ['object']
Out[16]: True
I will be grateful to know the reasons.