You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 23:55:18