Python Programming language learning : stay pandas Set a field as an index column in , And in dataframe Specify the index column in
Catalog
stay pandas Set a field as an index column in , And in dataframe Specify the index column in
#T1、 utilize pd.DataFrame The index column() function automatically specifies the index column
#T2、 utilize set_index Function to manually specify the index column
# encoding: utf-8
import pandas as pd
#T1、 utilize pd.DataFrame The index column() function automatically specifies the index column
df01=pd.read_csv('600519.csv')
df02 = pd.DataFrame(df01[' Opening price '].values,columns = [' Opening price '], index=df01[' date '])
print(df02.head())
#T2、 utilize set_index Function to manually specify the index column
df01=pd.read_csv('600519.csv')
df01 = df01.set_index(df01[' date '])
print(df01.head())