import pandas as pd
df = pd.read_csv('E:\\python\\IP\\1.csv')
查看列索引信息
df.index
RangeIndex(start=0, stop=53, step=1)
查看行索引信息
df.columns
Index(['Unnamed: 0', 'Unnamed: 1', 'Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4',
'Unnamed: 5', 'Unnamed: 6', 'Unnamed: 7', 'Unnamed: 8', 'Unnamed: 9',
'Unnamed: 10', 'Unnamed: 11', 'Unnamed: 12', 'Unnamed: 13',
'Unnamed: 14', 'Unnamed: 15', 'Unnamed: 16', 'Unnamed: 17',
'Unnamed: 18', 'Unnamed: 19', 'Unnamed: 20', 'Unnamed: 21',
'Unnamed: 22', 'Unnamed: 23', 'Unnamed: 24', 'Unnamed: 25',
'Unnamed: 26', 'Unnamed: 27', 'Unnamed: 28', 'Unnamed: 29',
'Unnamed: 30', 'Unnamed: 31', 'Unnamed: 32', 'Unnamed: 33',
'Unnamed: 34', 'Unnamed: 35', 'Unnamed: 36', 'Unnamed: 37',
'Unnamed: 38', 'Unnamed: 39', 'Unnamed: 40', 'Unnamed: 41',
'Unnamed: 42', 'Unnamed: 43', 'Unnamed: 44', 'Unnamed: 45',
'Unnamed: 46'],
dtype='object')
转换为numpy数组
arr = df.to_numpy()
arr[0]
array(['科目\\时间', '2019-12-31', '2019-09-30', '2019-06-30', '2019-03-31',
'2018-12-31', '2018-09-30', '2018-06-30', '2018-03-31',
'2017-12-31', '2017-09-30', '2017-06-30', '2017-03-31',
'2016-12-31', '2016-09-30', '2016-06-30', '2016-03-31',
'2015-12-31', '2015-09-30', '2015-06-30', '2015-03-31',
'2014-12-31', '2014-09-30', '2014-06-30', '2014-03-31',
'2013-12-31', '2013-09-30', '2013-06-30', '2013-03-31',
'2012-12-31', '2012-09-30', '2012-06-30', '2012-03-31',
'2011-12-31', '2011-09-30', '2011-06-30', '2011-03-31',
'2010-12-31', '2010-09-30', '2010-06-30', '2010-03-31',
'2009-12-31', '2009-09-30', '2009-06-30', '2008-12-31',
'2007-12-31', '2006-12-31'], dtype=object)
直接设置行名称为首行内容
df.columns=arr[0]
df.columns
Index(['科目\时间', '2019-12-31', '2019-09-30', '2019-06-30', '2019-03-31',
'2018-12-31', '2018-09-30', '2018-06-30', '2018-03-31', '2017-12-31',
'2017-09-30', '2017-06-30', '2017-03-31', '2016-12-31', '2016-09-30',
'2016-06-30', '2016-03-31', '2015-12-31', '2015-09-30', '2015-06-30',
'2015-03-31', '2014-12-31', '2014-09-30', '2014-06-30', '2014-03-31',
'2013-12-31', '2013-09-30', '2013-06-30', '2013-03-31', '2012-12-31',
'2012-09-30', '2012-06-30', '2012-03-31', '2011-12-31', '2011-09-30',
'2011-06-30', '2011-03-31', '2010-12-31', '2010-09-30', '2010-06-30',
'2010-03-31', '2009-12-31', '2009-09-30', '2009-06-30', '2008-12-31',
'2007-12-31', '2006-12-31'],
dtype='object')