2019-01-16
阅读量:
713
如何将pandas对象转换为指定的dtype(1)
Python是一种用于数据分析的优秀语言,主要是因为以数据为中心的python包的奇妙生态系统。Pandas是其中一个软件包,可以更轻松地导入和分析数据。在本文中,我们使用“nba.csv
”文件下载CSV文件。
DataFrame.astype()函数用于将pandas对象强制转换为指定的dtype。astype()
function还提供将任何合适的现有列转换为分类类型的功能。
代码#1:转换权重列数据类型。
# importing pandas as pd
import pandas as pd
# Making data frame from the csv file
df = pd.read_csv("nba.csv")
# Printing the first 10 rows of
# the data frame for visualization
df[:10]






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论