Convert pandas DataFrame Index to List & NumPy Array in Python (2 Examples) | Extract Data Indices

Publicado em: 11 Abril 2022
no canal de: Statistics Globe
879
22

How to get the indices of a pandas DataFrame as a list or a NumPy array in the Python programming language. More details: https://statisticsglobe.com/convert-p...
R code of this video:

import pandas as pd # Import pandas library

data = pd.DataFrame({"x1":range(1, 10), # Create pandas DataFrame
"x2":["a", "b", "c", "d", "e", "d", "c", "b", "a"],
"x3":range(10, 1, - 1)})
print(data) # Print pandas DataFrame

data_index1 = data.index.tolist() # Extract as list object
print(data_index1) # Print index as list

data_index2 = data.index.values # Extract as NumPy array
print(data_index2) # Print index as NumPy array

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – Group for Discussions & Questions:   / statisticsglobe  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – Group for Discussions & Questions:   / 12555223  
Twitter:   / joachimschork  

Music by bensound.com


Nesta página do site você pode assistir ao vídeo on-line Convert pandas DataFrame Index to List & NumPy Array in Python (2 Examples) | Extract Data Indices duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Statistics Globe 11 Abril 2022, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 879 vezes e gostou 22 espectadores. Boa visualização!