热线电话:13121318867

登录
2018-12-19 阅读量: 779
复制函数和统计数据类型函数

对于datetime64 [ns]类型,NaT表示缺少的,可以由单个dtype(datetime64 [ns])中的NumPy表示。pandas对象提供NaT和之间的互操作性NaN

In [14]: df2 = df.copy()

In [15]: df2['timestamp'] = pd.Timestamp('20120101')

In [16]: df2
Out[16]:
one two three four five timestamp
a -0.166778 0.501113 -0.355322 bar False 2012-01-01
c -0.337890 0.580967 0.983801 bar False 2012-01-01
e 0.057802 0.761948 -0.712964 bar True 2012-01-01
f -0.443160 -0.974602 1.047704 bar False 2012-01-01
h -0.717852 -1.053898 -0.019369 bar False 2012-01-01

In [17]: df2.loc[['a','c','h'],['one','timestamp']] = np.nan

In [18]: df2
Out[18]:
one two three four five timestamp
a NaN 0.501113 -0.355322 bar False NaT
c NaN 0.580967 0.983801 bar False NaT
e 0.057802 0.761948 -0.712964 bar True 2012-01-01
f -0.443160 -0.974602 1.047704 bar False 2012-01-01
h NaN -1.053898 -0.019369 bar False NaT

In [19]: df2.get_dtype_counts()
Out[19]:
float64 3
object 1
bool 1
datetime64[ns] 1
dtype: int64
0.0000
2
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子