<jupyter_start><jupyter_text>Convertir un fichier XML en *data frame*Votre objectif est de convertir le [fichier XML des constellations](../files/constellations.xml) en *data frame* avec la librairie *Pandas*.<jupyter_code># your code here

import pandas as pd
import xml.etree.ElementTree as ET

tree = ET.parse('../files/constellations.xml')
root = tree.getroot()

constellations = list()
origins = list()
degs2 = list()
percents = list()

for item in root.iterfind('constellation'):

    origins.append(item.attrib['origin'])
    constellations.append(item.find('name').text)
    
    for area in item.iter('area'):
        if area.attrib['unit'] == 'deg2':
            degs2.append(float(area.text))
        else:
            percents.append(float(area.text))

df = pd.DataFrame({
    'constellation': constellations,
    'origin': origins,
    'deg2': degs2,
    'percent': percents
})<jupyter_output><empty_output><jupyter_text>Dans un second temps, trouvez un moyen de dire combien de comptabiliser le nombre de constellations découvertes par Ptolémée et par Lacaille.<jupyter_code># your code here

from collections import Counter

print(Counter(df['origin']))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12353923205342238, 'fraction_numerical': 0.004173622704507512, 'mean_word_length': 4.45, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '572689', 'license': 'MIT', 'n_tokens_mistral': 405, 'n_tokens_neox': 398, 'n_words': 102, 'path': '7.everything-else/answers/2.xml-to-data-frame.ipynb', 'repo_name': 'Alex-bzh/python-M2TTD', 'size': '1198'}