OB
Size: a a a
OB
OB
def xml_df(city, path):
path = path + city + '.xml'
dfcols = ['id', 'name' ,'available', 'price', 'dimensions']
root = et.parse(path)
rows = root.findall('.//offer')
xml_data = [[row.get('id'), row.find('name').text, row.get('available'), row.find('price').text,
row.find('dimensions').text] for row in rows if hasattr(row.find('dimensions'), 'text')]
xml_data.extend([[row.get('id'), row.find('name').text, row.get('available'), row.find('price').text,
''] for row in rows if not hasattr(row.find('dimensions'), 'text')])
df_xml = pd.DataFrame(xml_data, columns=dfcols)
return df_xml
MY
def xml_df(city, path):
path = path + city + '.xml'
dfcols = ['id', 'name' ,'available', 'price', 'dimensions']
root = et.parse(path)
rows = root.findall('.//offer')
xml_data = [[row.get('id'), row.find('name').text, row.get('available'), row.find('price').text,
row.find('dimensions').text] for row in rows if hasattr(row.find('dimensions'), 'text')]
xml_data.extend([[row.get('id'), row.find('name').text, row.get('available'), row.find('price').text,
''] for row in rows if not hasattr(row.find('dimensions'), 'text')])
df_xml = pd.DataFrame(xml_data, columns=dfcols)
return df_xml
ЕБ
ВЛ
YP
ВЛ
YP
V
OO
V
OO
V
V
С
С
A
AG
from google.colab import drive
drive.mount('/content/drive')
os.chdir("drive/My Drive/ML/TextGen")
A