我使用pymongo从mongo数据库创建了一个pandas数据帧。在数据库中,列中的元素看起来像整数,但当我创建dataframe时,它们是浮点数。我希望它们是整数。我怎么能做到呢?我只想换个专栏
尝试
X = X.astype({'x':'int'})
myclient = pymongo.MongoClient("mongodb+srv://bla-bla")
mydb = myclient["p"]
mycol = mydb["aDB"]
colnames={ "_id": 1,"x":1, "y":1,"z":1}
X = pd.DataFrame(list(mycol.find({},colnames)))
尝试:
相关问题 更多 >
编程相关推荐