如何将Featureset对象转换为Python DataFrame
解决wbgapi转DataFrame的AttributeError问题
wb.source.info()返回的是Featureset类型对象,这类对象不能直接传入pandas的DataFrame()构造器,需要调用它自带的to_df()方法完成转换:import wbgapi as wb # 获取数据源信息并转为DataFrame df = wb.source.info().to_df()- 也可以直接调用
wb.source.DataFrame()方法,一步获取DataFrame格式的数据源信息:import wbgapi as wb df = wb.source.DataFrame()
wbgapi中大部分集合类返回对象都内置了to_df()方法,专门用于转换为pandas DataFrame,直接用pandas构造器转换原生集合对象会因属性不匹配触发报错。
内容的提问来源于stack exchange,提问作者ponderwonder
相关产品推荐
相关产品推荐

