本文整理汇总了Python中pandas.core.style.Styler.render方法的典型用法代码示例。如果您正苦于以下问题:Python Styler.render方法的具体用法?Python Styler.render怎么用?Python Styler.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.style.Styler
的用法示例。
在下文中一共展示了Styler.render方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_table_attributes
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_table_attributes(self):
attributes = 'class="foo" data-bar'
styler = Styler(self.df, table_attributes=attributes)
result = styler.render()
self.assertTrue('class="foo" data-bar' in result)
result = self.df.style.set_table_attributes(attributes).render()
self.assertTrue('class="foo" data-bar' in result)
示例2: test_uuid
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_uuid(self):
styler = Styler(self.df, uuid='abc123')
result = styler.render()
self.assertTrue('abc123' in result)
styler = self.df.style
result = styler.set_uuid('aaa')
self.assertTrue(result is styler)
self.assertEqual(result.uuid, 'aaa')
示例3: test_caption
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_caption(self):
styler = Styler(self.df, caption='foo')
result = styler.render()
self.assertTrue(all(['caption' in result, 'foo' in result]))
styler = self.df.style
result = styler.set_caption('baz')
self.assertTrue(styler is result)
self.assertEqual(styler.caption, 'baz')
示例4: test_table_styles
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_table_styles(self):
style = [{'selector': 'th', 'props': [('foo', 'bar')]}]
styler = Styler(self.df, table_styles=style)
result = ' '.join(styler.render().split())
self.assertTrue('th { foo: bar; }' in result)
styler = self.df.style
result = styler.set_table_styles(style)
self.assertTrue(styler is result)
self.assertEqual(styler.table_styles, style)
示例5: test_render
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_render(self):
df = pd.DataFrame({"A": [0, 1]})
style = lambda x: pd.Series(["color: red", "color: blue"], name=x.name)
s = Styler(df, uuid='AB').apply(style).apply(style, axis=1)
s.render()
示例6: test_render_double
# 需要导入模块: from pandas.core.style import Styler [as 别名]
# 或者: from pandas.core.style.Styler import render [as 别名]
def test_render_double(self):
df = pd.DataFrame({"A": [0, 1]})
style = lambda x: pd.Series(["color: red; border: 1px",
"color: blue; border: 2px"], name=x.name)
s = Styler(df, uuid='AB').apply(style)
s.render()