I'm slowly working my way in using spyder Python3.6, hope you can give me some solutions to this question:
我正在慢慢使用spyder Python3.6,希望你能给我一些解决这个问题的方法:
An Excel file [ c1.xlsx ] which contains 10 columns (from column a to e) and 20 rows(from row 2 to 21), now I want to create a sheet using python (columns namely A, B, C, E). I need all data from these 20 rows from column a, b, c and e.
Excel文件[c1.xlsx]包含10列(从列a到e)和20行(从第2行到第21行),现在我想使用python创建工作表(列为A,B,C,E) 。我需要来自a,b,c和e列的这20行的所有数据。
So I hope I will get this as result
所以我希望我能得到这个结果
I alread have some codes:
我发现了一些代码:
import pandas as pd
import os
dir = os.path.join('..' , 'Climate')
fname = 'C1.xlsx'
fpath = os.path.join(dir,fname)
data = pd.read_excel(fpath,sheetname = 'sheet1',header=0)
df_Ct = pd.columns = (['A', 'B', 'C', 'E'])
how can I continue to read these values?
我该如何继续阅读这些值?
1 个解决方案
#1
0
According to documentation, "read_excel" returns a DataFrame. So you already have the data.
根据文档,“read_excel”返回一个DataFrame。所以你已经有了数据。
Then, you can access a column in the DataFrame by referring to its name, like:
然后,您可以通过引用其名称来访问DataFrame中的列,例如:
df['A']
DF [ 'A']
You can then construct a new data frame and write it out.
然后,您可以构造一个新的数据框并将其写出来。
#1
0
According to documentation, "read_excel" returns a DataFrame. So you already have the data.
根据文档,“read_excel”返回一个DataFrame。所以你已经有了数据。
Then, you can access a column in the DataFrame by referring to its name, like:
然后,您可以通过引用其名称来访问DataFrame中的列,例如:
df['A']
DF [ 'A']
You can then construct a new data frame and write it out.
然后,您可以构造一个新的数据框并将其写出来。