Convert XML to DataFrame in Python using pandas - Part #2

preview_player
Показать описание
This demo explains everything you need to successfully apply the steps in your project

setup on windows:

python -m pip install -U pip setuptools
pip3 install jupyter
jupyter notebook

ModuleNotFoundError: No module named 'requests'
pip install requests

ModuleNotFoundError: No module named 'pandas'
pip install pandas

1. Imports

import requests
import pandas as pd

2. get XML

3. define function

def xml2df(xml_data):
root = ET.XML(xml_data) # element tree
all_records = []
for i, child in enumerate(root):
record = {}
for subchild in child:
return pd.DataFrame(all_records)

4. Test

df = xml2df(xml_data)

Part #1

Рекомендации по теме
Комментарии
Автор

Hi Adimulam Natarajan, thanks for video. I have many columns with same names, i dont want to drop those columns. i need to create new column names, if the column name are repeating. Can you please help me out.

burajyothi
Автор

Is xml_data a string with the xml file like opened in note pad?

walterpaiva
Автор

how can we load a local xml file in jupyter?

ANAND
Автор

How will write the get data step if we import an xml in notebook

anaghab
Автор

try to be faster next time u spent half video just for the introduction, none has got all this time available.

theforester_
join shbcf.ru