I am trying to get the datatype of the column of dataframe using dtype, but dtype giving me wrong value when I am adding an empty row in the dataframe.
when i am adding one empty row then dtype will give wrong value for int --->float,float-->int.
example1:(without blank row dtype function working fine)
Video Title Up Ratings Down Ratings Views User Name Subscribers
0 Adelaide 1295 1158259 600.5 Bob 25000
1 Brisbane 5905 1857594 1146.4 Tom 30000
2 Darwin 112 120900 1714.7 Dave 15000
3 Hobart 1357 205556 619.5 Sally 15005
4 Sydney 2058 4336374 1214.8 Rick 20000
5 Melbourne 1566 3806092 646.9 Mary 31111
6 Perth 5386 1554769 869.4 Roberta 11000
In [21]: df.dtypes
Out[21]:
Video Title object
Up Ratings int64
Down Ratings int64
Views float64
User Name object
Subscribers int64
dtype: object
example:(when I am getting a different dtype when I am adding an empty row in dataframe.)
Video Title Up Ratings Down Ratings Views User Name Subscribers
0
1 Adelaide 1295 1158259 600.5 Bob 25000
2 Brisbane 5905 1857594 1146.4 Tom 30000
3 Darwin 112 120900 1714.7 Dave 15000
4
5 Hobart 1357 205556 619.5 Sally 15005
6 Sydney 2058 4336374 1214.8 Rick 20000
7 Melbourne 1566 3806092 646.9 Mary 31111
8 Perth 5386 1554769 869.4 Roberta 11000
In [21]: df.dtypes
Out[21]:
Video Title object
Up Ratings float64
Down Ratings float64
Views int64
User Name object
Subscribers float64
dtype: object
can anyone suggest me how to correct the dtype function functionality without converting datatype of columns explicitly from code end.?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…