<jupyter_start><jupyter_text>Criando a tupla<jupyter_code>hier_index = list(zip(outside,inside))
hier_index
hier_index = pd.MultiIndex.from_tuples(hier_index)
hier_index<jupyter_output><empty_output><jupyter_text>Criando dataframe multinível<jupyter_code>df = pd.DataFrame(np.random.randn(6, 2), index = hier_index, columns = ['A', 'B'])
df<jupyter_output><empty_output><jupyter_text>Acessando dados no dataframe multinível<jupyter_code>df.loc['G1']
df.index.names = ['Grupo', 'Numero']
df
df.xs('G1')
df.xs(1, level = 'Numero')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15053763440860216, 'fraction_numerical': 0.008960573476702509, 'mean_word_length': 10.893617021276595, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '138784', 'license': 'MIT', 'n_tokens_mistral': 245, 'n_tokens_neox': 236, 'n_words': 30, 'path': 'python-data-science-machine-learning/3-pandas/dataframe-indice-multinivel-pandas.ipynb', 'repo_name': 'GlauberC/udemy-cursos', 'size': '558'}