本文整理汇总了Python中pandas.io.formats.style.Styler.render方法的典型用法代码示例。如果您正苦于以下问题:Python Styler.render方法的具体用法?Python Styler.render怎么用?Python Styler.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.formats.style.Styler
的用法示例。
在下文中一共展示了Styler.render方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_render_empty_dfs
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.style.Styler import render [as 别名]
def test_render_empty_dfs(self):
empty_df = DataFrame()
es = Styler(empty_df)
es.render()
# An index but no columns
DataFrame(columns=['a']).style.render()
# A column but no index
DataFrame(index=['a']).style.render()
示例2: test_table_attributes
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.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()
assert 'class="foo" data-bar' in result
result = self.df.style.set_table_attributes(attributes).render()
assert 'class="foo" data-bar' in result
示例3: test_uuid
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.style.Styler import render [as 别名]
def test_uuid(self):
styler = Styler(self.df, uuid='abc123')
result = styler.render()
assert 'abc123' in result
styler = self.df.style
result = styler.set_uuid('aaa')
assert result is styler
assert result.uuid == 'aaa'
示例4: test_caption
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.style.Styler import render [as 别名]
def test_caption(self):
styler = Styler(self.df, caption='foo')
result = styler.render()
assert all(['caption' in result, 'foo' in result])
styler = self.df.style
result = styler.set_caption('baz')
assert styler is result
assert styler.caption == 'baz'
示例5: test_uuid
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.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')
示例6: test_caption
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.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')
示例7: test_table_styles
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.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())
assert 'th { foo: bar; }' in result
styler = self.df.style
result = styler.set_table_styles(style)
assert styler is result
assert styler.table_styles == style
示例8: test_render_double
# 需要导入模块: from pandas.io.formats.style import Styler [as 别名]
# 或者: from pandas.io.formats.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()