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

preview_player
Показать описание
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

print(data_index1) # Print index as list

print(data_index2) # Print index as NumPy array

Follow me on Social Media:

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

what are the use cases of using an array? I've not had any instances of choosing an array format instead of a data frame. Assuming it is more useful with extensive mathematical operations, and statistical or financial modeling. Would be interested to see examples of these

infamousprince