创建者停止更新和支持的DataFrame-image模块的选项(将样式的DataFrame转换为图像)
始终在社区的最佳答案中,图像的格式化完美,根据数据完美拟合列,而不会丢失质量,使用dataframe-image
:
https://stackoverflow.com/a/65954710/11462274
https://stackoverflow.com/a/70550426/114622274
用途简化并在代码中几乎没有空间,一条可以调用该函数的行完成了所有工作。
官方模块页:
https://github.com/dexplo/dataframe_image
org/project/dataframe-image/“ rel =“ nofollow noreferrer”> https://pypi.org/project/dataframe-image/
使用此模块时,发出了几个有关更改的未来警报消息,发出了代码,代码根据我的研究,已经变老了,不再更新。如果模块更新,并且不再接受某些功能的使用,这将来可能会导致问题。
例如:
FutureWarning: this method is deprecated in favour of `Styler.to_html()`
html = '<div>' + obj.render() + '</div>'
我使用它来保存图像中的风格化数据框架:
import pandas as pd
import dataframe_image as dfi
def csv_to_image(csv_file,name_file):
df = pd.read_csv(csv_file)
df = df.style.set_table_styles([dict(selector='th', props=[('text-align', 'center'),('background-color', '#40466e'),('color', 'white')])])
df.set_properties(**{'text-align': 'center'}).hide(axis='index')
pd.set_option('colheader_justify', 'center')
dfi.export(df, name_file + ".png")
我想知道是否有任何可以执行相同服务的模块,并且没有被创建的模块。
例如,我的CSV数据进行测试:
DATA,HORA,CAMPEONATO,JOGO,CANAIS
21/04/2022,"08:00 Ao vivo 77'",Liga dos Campeões Asiática,0 Shandong Taishan x 0 Lion City Sailors FC,STAR+
21/04/2022,"08:00 Ao vivo 78'",Liga dos Campeões Asiática,2 BG Pathum United x 0 United City,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Kawasaki Frontale x Johor Darul Takzim,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Melbourne City x Jeonnam Dragons,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Daegu FC x Urawa Red Diamonds,STAR+
21/04/2022,14:00,LaLiga,Espanhol x Rayo Vallecano,STAR+
21/04/2022,14:00,LaLiga,Levante x Sevilla,"ESPN 4, STAR+"
21/04/2022,15:00,LaLiga,Cadiz x Athletic Bilbao,"ESPN 3, STAR+"
21/04/2022,15:00,Campeonato Equatoriano,Mushuc Runa x Macara,STAR+
21/04/2022,15:45,Campeonato Inglês,Burnley x Southampton,"ESPN 2, STAR+"
21/04/2022,16:00,Copa da Liga Argentina,Sarmiento x Defensa y Justicia,STAR+
21/04/2022,16:15,Taça de Portugal,FC Porto x Sporting,STAR+
21/04/2022,16:30,LaLiga,Real Sociedad x Barcelona,"ESPN, STAR+"
21/04/2022,16:30,Brasileirão Série B,Grêmio x Guarani,PREMIERE FC
21/04/2022,16:30,Campeonato Pernambucano,Náutico x Retrô FC Brasil,"GLOBO(PE), PREMIERE 2"
21/04/2022,17:00,Campeonato Piauiense,Parnahyba x Fluminense PI,ELEVENSPORTS.COM
21/04/2022,17:30,Campeonato Equatoriano,SD Aucas x U Católica,STAR+
21/04/2022,19:00,Brasileirão Série B,Londrina x Grêmio Novorizontino,"PREMIERE FC, SPORTV"
21/04/2022,19:00,Campeonato Acreano,Rio Branco AC x Galvez AC,ELEVENSPORTS.COM
21/04/2022,19:00,Campeonato Capixaba,Serra x Real Noroeste Capixaba,"TVE(ES), YOUTUBE(TVE ES)"
21/04/2022,20:00,Campeonato Equatoriano,Cumbaya FC x Emelec,STAR+
21/04/2022,21:30,Copa do Brasil,Atlético GO x Cuiabá EC,"SPORTV, PREMIERE FC"
最终结果:
Always the best answers here from the community and that the image is perfectly formatted, that perfectly fits the columns according to the data, without loss of quality, the use of dataframe-image
is indicated:
https://stackoverflow.com/a/65954710/11462274
https://stackoverflow.com/a/70550426/11462274
The use is simplified and takes up almost no space in the code, a single line to call the function does all the work.
Official module page:
https://github.com/dexplo/dataframe_image
https://pypi.org/project/dataframe-image/
When using this module, several future alert messages about changes are issued, the code has become old and no longer update according to my research. This may cause problems in the future if a module is updated and no longer accepts the use of some function.
Like for example:
FutureWarning: this method is deprecated in favour of `Styler.to_html()`
html = '<div>' + obj.render() + '</div>'
I use it to save a stylized DataFrame in image:
import pandas as pd
import dataframe_image as dfi
def csv_to_image(csv_file,name_file):
df = pd.read_csv(csv_file)
df = df.style.set_table_styles([dict(selector='th', props=[('text-align', 'center'),('background-color', '#40466e'),('color', 'white')])])
df.set_properties(**{'text-align': 'center'}).hide(axis='index')
pd.set_option('colheader_justify', 'center')
dfi.export(df, name_file + ".png")
I would like to know if there is any module that does the same service and that has not been left out by the created.
My CSV data for example to tests:
DATA,HORA,CAMPEONATO,JOGO,CANAIS
21/04/2022,"08:00 Ao vivo 77'",Liga dos Campeões Asiática,0 Shandong Taishan x 0 Lion City Sailors FC,STAR+
21/04/2022,"08:00 Ao vivo 78'",Liga dos Campeões Asiática,2 BG Pathum United x 0 United City,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Kawasaki Frontale x Johor Darul Takzim,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Melbourne City x Jeonnam Dragons,STAR+
21/04/2022,11:00,Liga dos Campeões Asiática,Daegu FC x Urawa Red Diamonds,STAR+
21/04/2022,14:00,LaLiga,Espanhol x Rayo Vallecano,STAR+
21/04/2022,14:00,LaLiga,Levante x Sevilla,"ESPN 4, STAR+"
21/04/2022,15:00,LaLiga,Cadiz x Athletic Bilbao,"ESPN 3, STAR+"
21/04/2022,15:00,Campeonato Equatoriano,Mushuc Runa x Macara,STAR+
21/04/2022,15:45,Campeonato Inglês,Burnley x Southampton,"ESPN 2, STAR+"
21/04/2022,16:00,Copa da Liga Argentina,Sarmiento x Defensa y Justicia,STAR+
21/04/2022,16:15,Taça de Portugal,FC Porto x Sporting,STAR+
21/04/2022,16:30,LaLiga,Real Sociedad x Barcelona,"ESPN, STAR+"
21/04/2022,16:30,Brasileirão Série B,Grêmio x Guarani,PREMIERE FC
21/04/2022,16:30,Campeonato Pernambucano,Náutico x Retrô FC Brasil,"GLOBO(PE), PREMIERE 2"
21/04/2022,17:00,Campeonato Piauiense,Parnahyba x Fluminense PI,ELEVENSPORTS.COM
21/04/2022,17:30,Campeonato Equatoriano,SD Aucas x U Católica,STAR+
21/04/2022,19:00,Brasileirão Série B,Londrina x Grêmio Novorizontino,"PREMIERE FC, SPORTV"
21/04/2022,19:00,Campeonato Acreano,Rio Branco AC x Galvez AC,ELEVENSPORTS.COM
21/04/2022,19:00,Campeonato Capixaba,Serra x Real Noroeste Capixaba,"TVE(ES), YOUTUBE(TVE ES)"
21/04/2022,20:00,Campeonato Equatoriano,Cumbaya FC x Emelec,STAR+
21/04/2022,21:30,Copa do Brasil,Atlético GO x Cuiabá EC,"SPORTV, PREMIERE FC"
And the final result:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
pandas
.to_html()
,然后使用imgkit
写入文件。You could use
pandas
.to_html()
, then useimgkit
to write to file.