""" * Assignment: Pandas Read XSLT Plants * Complexity: medium * Lines of code: 4 lines * Time: 5 min English: 1. Read data from `DATA` as `result: pd.DataFrame` 2. Use XSLT transformation 3. Make sure that columns and indexes are named properly 4. Calculate average cost of flower 5. Run doctests - all must succeed Polish: 1. Wczytaj dane z `DATA` jako `result: pd.DataFrame` 2. Użyj transformaty XSLT 3. Upewnij się, że nazwy kolumn i indeks są dobrze ustawione 4. Wylicz średni koszt kwiatów 5. Uruchom doctesty - wszystkie muszą się powieść Hints: * `pip install --upgrade lxml` Tests: >>> import sys; sys.tracebacklimit = 0 >>> type(result) is pd.DataFrame True >>> len(result) > 0 True >>> result English Name Latin Name Cost 0 Bloodroot Sanguinaria canadensis $2.44 1 Columbine Aquilegia canadensis $9.37 2 Marsh Marigold Caltha palustris $6.81 3 Cowslip Caltha palustris $9.90 """ import pandas as pd from io import StringIO from lxml.etree import XML, XSLT, parse DATA = """ Bloodroot Sanguinaria canadensis 4 Mostly Shady $2.44 031599 Columbine Aquilegia canadensis 3 Mostly Shady $9.37 030699 Marsh Marigold Caltha palustris 4 Mostly Sunny $6.81 051799 Cowslip Caltha palustris 4 Mostly Shady $9.90 030699 """ TEMPLATE = """
English Name Latin Name Cost
""" # Solution transform = XSLT(XML(TEMPLATE)) data = parse(StringIO(DATA)) html = str(transform(data)) dfs = pd.read_html(html) result = dfs[0]