Linux 拨号vps windows公众号手机端

jupyter如何查看数据类型

lewis 1年前 (2024-05-16) 阅读数 43 #程序编程
文章标签 jupyter

在jupyter notebook中,可以使用type()函数来查看变量的数据类型。例如:

x = 5
print(type(x))  # 输出:<class 'int'>

y = "hello"
print(type(y))  # 输出:<class 'str'>

z = [1, 2, 3]
print(type(z))  # 输出:<class 'list'>

另外,使用df.dtypes属性可以查看DataFrame中每列的数据类型。例如:

import pandas as pd

df = pd.DataFrame({'A': [1, 2, 3], 'B': ['a', 'b', 'c']})
print(df.dtypes)

这样就可以看到DataFrame中每列的数据类型。

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门