【问题标题】:Exporting a dataframe into an image将数据框导出到图像中
【发布时间】:2023-01-20 00:10:29
【问题描述】:

我目前正在尝试将数据框导出为 png 文件。直到几天前,我才能够使用 dataframe_image 模块,使用 dfi.export() 函数成功地做到这一点。现在它返回错误:SyntaxError: not a PNG file 这是我目前使用的功能。我怎样才能解决这个问题?

def imprimir_fig():
                        fig = pd.DataFrame(out)
                        pd.set_option('display.colheader_justify', 'center')
                        fig.columns=['Tipo','Valorizada']
                        fig= fig.style.hide_index()
                        fig= fig.set_properties(**{'text-align': 'center'})
                        fig= fig.set_table_styles([dict(selector = 'th', props=[('text-align', 'center')])])
                        dfi.export(fig, f'{dirG}\\moneda {comitente}.png')
                        return(fig)
                    imprimir_fig()

我尝试使用 dfi 的其他功能,但它似乎不再起作用,有没有人遇到过类似的问题?

【问题讨论】:

    标签: python dataframe image


    【解决方案1】:

    我使用 dfi.export() 函数中的一个额外参数修复了它:

    dfi.export(fig, f'{dirG}\compo {comitente}-{i}.png',table_conversion = 'matplotlib')
    

    【讨论】:

      猜你喜欢
      • 2014-12-27
      • 2017-07-23
      • 2017-04-30
      • 2011-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-17
      相关资源
      最近更新 更多