{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 6 - XML" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1 Add the necessary libraries (xml and pandas)." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2 Save the XML structure shown below as a string in a variable. In addition, load the content from the file *users_first.xml* into another variable." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# Lawrence Burke(815) 571-8746vulputate.lacus@elitfermentum.net
P.O. Box 478, 5254 Mi St.Mexico22044
Angela Hinton(997) 412-6965elit.dictum@egestas.net
696-4409 Nunc Rd.Germany661217
Whitney Flowers1-573-471-9738consectetuer.adipiscing.elit@ridiculusmus.ca
6978 Et, Av.Indonesia28164
Darius Burt1-675-212-4934sociis.natoque@ut.org
7705 Ut StreetIndonesia94783-300
Solomon Blairpede.suspendisse.dui@commodoat.edu
Ap #877-8946 Sociosqu StreetGermany113513
" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3 From the contents of both variables, form lists C1 and C2, in which the contents of the XML data are stored as dictionary-type objects. **NOTE**: the attributes presented at the record level must be included in the objects and the identifiers under the address identifier must be brought to a higher level next to user's other properties!\n", "\n", "Below is a model showing the structure of the first object:\n", "\n", "
[{\n",
    "    'type': 'customer',\n",
    "    'name': 'Morgan Sykes',\n",
    "    'phone': '1-183-546-6564',\n",
    "    'email': 'lorem.auctor@vulputatemauris.net',\n",
    "    'streetaddress' : '2594 Tellus St.',\n",
    "    'country': 'Russian Federation',\n",
    "    'postalZip': '584585'\n",
    "}]
\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "4 Convert both lists into dataframes and finally combine them into one dataframe (remember to reset the index of the new dataframe!). Print the content of the generated dataframe."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "#"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "5 Some users are missing a phone number. Print the number of these users."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "8b50b686190c14b0a5176f7257ee24c43a886d1ffbaa1fefb478a1f90f0f3afb"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 64-bit ('base': conda)",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}