Skip to content

Commit ed7c1f6

Browse files
committed
format multiple selectors
1 parent f904213 commit ed7c1f6

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

pandas/io/formats/style.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def _translate(self):
566566
"body": body,
567567
"uuid": uuid,
568568
"precision": precision,
569-
"table_styles": table_styles,
569+
"table_styles": _format_table_styles(table_styles),
570570
"caption": caption,
571571
"table_attributes": table_attr,
572572
}
@@ -2077,6 +2077,26 @@ def _maybe_convert_css_to_tuples(style: CSSProperties) -> CSSList:
20772077
return style
20782078

20792079

2080+
def _format_table_styles(styles: CSSStyles) -> CSSStyles:
2081+
"""
2082+
looks for multiple CSS selectors and separates them:
2083+
[{'selector': 'td, th', 'props': 'a:v;'}]
2084+
---> [{'selector': 'td', 'props': 'a:v;'},
2085+
{'selector': 'th', 'props': 'a:v;'}]
2086+
"""
2087+
return [
2088+
item
2089+
for sublist in [
2090+
[
2091+
{"selector": x, "props": style["props"]}
2092+
for x in style["selector"].split(",")
2093+
]
2094+
for style in styles
2095+
]
2096+
for item in sublist
2097+
]
2098+
2099+
20802100
def _non_reducing_slice(slice_):
20812101
"""
20822102
Ensure that a slice doesn't reduce to a Series or Scalar.

0 commit comments

Comments
 (0)