扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

jupyter如何查看数据类型

扬州沐宇科技
2024-05-23 16:15:08
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中每列的数据类型。

扫码添加客服微信