[英]converting a dataframe from float64 to object using dtype
I have written this function long time but when i tried it now im getting an error message我已经写了这个 function 很长时间但是当我现在尝试它时我收到一条错误消息
def saveToDisk(i):
print("saving ***")
name='kenos'+str(i)+'.csv'
d = {'adId':adId, 'Title':title,'Price':prices,'Description':description, 'Location':location,'Ddate Posted':datePosted, 'Location':location, 'Features' : features, 'URL':urlToSave, 'Type' : listingType}
df = pd.concat([pd.Series(v, name=k) for k, v in d.items()], axis=1 )
df.to_csv(name,index=False)
resetAll()
and i get this error message我收到此错误消息
"df = pd.concat([pd.Series(v, name=k) for k, v in d.items()], axis=1 )
DeprecationWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning."
im not really sure how to resolve this issue, i appreciate if i could get any help.我不确定如何解决这个问题,如果我能得到任何帮助,我将不胜感激。 thanks
谢谢
Just had this problem myself.我自己刚遇到这个问题。
As the error warning suggests, for empty series the default will be object
rather than float64
.正如错误警告所暗示的,对于空系列,默认
object
而不是float64
。 To remove the warning specify the default data type when instantiating the Series in your code.要删除警告,请在代码中实例化 Series 时指定默认数据类型。
Try this code:试试这个代码:
df = pd.concat([pd.Series(v, name=k, dtype = 'object') for k, v in d.items()], axis=1)
Documentation at this link: What's new in 1.0.0 (January 29, 2020)此链接中的文档: 1.0.0 中的新增功能(2020 年 1 月 29 日)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.