python - .astype ("int") 或 .astype(int)?有和没有引号/双引号之间有什么区别吗?

标签 python pandas

我有一个 DataFrame,其中一列由浮点型对象组成。我想转换为 int。正如我所尝试的,.astype("int")astype(int) 方法都有效。我只是想知道是否有任何区别?

最佳答案

据我所知,没有什么大的区别......

.astype(dtype) 应该接受 numpy.dtype() 接受的所有内容.

在内部它是这样做的:

dtype = np.dtype(dtype)

关于python - .astype ("int") 或 .astype(int)?有和没有引号/双引号之间有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41791947/

相关文章:

python - 狮身人面像 : force rebuild of html, 包括 autodoc

Python numpy 和 pandas 矩阵维度

python Pandas : How to group by and count unique values based on multiple columns?

python - Keras 没有使用完整的 CPU 内核进行训练

python - 如何将 scipy 行矩阵转换为 numpy 数组

python - Tkinter,Windows : How to view window in windows task bar which has no title bar?

python - 如果某个时间在某个时间范围内,则查找该时间并返回 Pandas 中的相应值?

python - 如何将一列的所有项目移动到 Pandas 的列中?

python - 带有热图调色板的条形图

python - 检查 .one() 是否为空 sqlAlchemy