Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files1845 unmodified lines18461847184818491850185118521853129 unmodified lines198319841985198619871988198919901991199219931994199519961845 unmodified lines""", unsafe_allow_html=True)st.code("""import pandas as pd# Sample DataFramedata = pd.DataFrame({'sepal_length': [1.5, 1.4, 1.5],129 unmodified lineselif st.session_state.current_page == "explore_xml":st.markdown("""<h3 style="color: #e25822;">Exploring XML</h3>""", unsafe_allow_html=True)st.write("""XML uses tags to structure semi-structured data.""")if st.button("Go Back"):navigate_to("main")#--------------------------------------------------------- HTML --------------------------------------------------------------------------------1845 unmodified lines184618471848184918501851129 unmodified lines1981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421151845 unmodified lines""", unsafe_allow_html=True)st.code("""# Sample DataFramedata = pd.DataFrame({'sepal_length': [1.5, 1.4, 1.5],129 unmodified lineselif st.session_state.current_page == "explore_xml":st.markdown("""<h3 style="color: #BB3385;">Extensible Markup Language(XML)</h3>""", unsafe_allow_html=True)st.write("""- **XML (Extensible Markup Language)** is a markup language used to store and transport data.- It is designed to be self-descriptive, making it easy to read and understand.- XML uses a tree structure where data is organized into nested elements.- Commonly used for:- Configuration files- Data interchange between systems- Storing structured data""")st.markdown("""<h3 style="color: #5b2c6f;">Element-wise XML Structure</h3>""", unsafe_allow_html=True)st.write("""An element-wise XML structure organizes data into nested elements, where each piece of information is an individual element.""")st.code("""<items><item><name>Item 1</name><price>100</price><category>Category A</category></item><item><name>Item 2</name><price>200</price><category>Category B</category></item></items>""", language="xml")st.code("""# Reading an element-wise XML filedf = pd.read_xml('element_structure.xml', xpath='/items/item')print(df)""", language="python")st.write("""**Output DataFrame**:""")st.table({'name': ['Item 1', 'Item 2'],'price': [100, 200],'category': ['Category A', 'Category B']})st.write("""### Explanation of the `xpath` Parameter:- `xpath='/items/item'`: Extracts all `<item>` elements from within `<items>`.- Useful for XML structures with data organized by child elements.""")st.markdown("""<h3 style="color: #5b2c6f;">Attribute XML Structure</h3>""", unsafe_allow_html=True)st.write("""An attribute XML structure stores data as attributes of tags, rather than as child elements.""")st.code("""<items><item name="Item 1" price="100" category="Category A" /><item name="Item 2" price="200" category="Category B" /></items>""", language="xml")st.code("""# Reading an attribute-based XML filedf = pd.read_xml('attribute_structure.xml', xpath='/items/item')print(df)""", language="python")st.write("""**Output DataFrame**:""")st.table({'name': ['Item 1', 'Item 2'],'price': [100, 200],'category': ['Category A', 'Category B']})st.write("""### Explanation of the `xpath` Parameter:- `xpath='/items/item'`: Extracts attributes of `<item>` elements.- Useful for XML structures where data is stored in attributes instead of nested elements.""")st.markdown("""<h3 style="color: #5b2c6f;">Exporting Element-wise XML Structure</h3>""", unsafe_allow_html=True)st.code("""# Sample DataFramedata = pd.DataFrame({'name': ['Item 1', 'Item 2'],'price': [100, 200],'category': ['Category A', 'Category B']})# Export the DataFrame to an element-wise XML filedata.to_xml('element_structure.xml', index=False, root_name='items', row_name='item')""", language="python")st.markdown("""<h3 style="color: #5b2c6f;">Exporting Attribute XML Structure</h3>""", unsafe_allow_html=True)st.code("""# Sample DataFramedata = pd.DataFrame({'name': ['Item 1', 'Item 2'],'price': [100, 200],'category': ['Category A', 'Category B']})# Export the DataFrame to an attribute-based XML filedata.to_xml('attribute_structure.xml', index=False, root_name='items', row_name='item', attr_cols=['name', 'price', 'category'])""", language="python")#--------------------------------------------------------- HTML --------------------------------------------------------------------------------
pages/Data Collection.py+125-6