-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyModule05.py
31 lines (25 loc) · 1.08 KB
/
MyModule05.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
def read_file(s1:str,n1:int,header,index_col):
DataFrame=pd.read_excel(s1,sheet_name=n1,header=header,index_col=index_col)
return DataFrame
def save_DF(s1:str,DF1,index_flag:bool,header_flag:bool):
DF1.to_excel(s1,index=index_flag,header=header_flag)
def create_DF3():
DF=pd.DataFrame([['za1','zb1','zc'],['za2','zb2','zc'],['za3','zb3','zc'],
['za4','zb4','zd'],['za5','zb5','zd'],['za6','zb6','zd'],
['za7','zb7','ze'],['za8','zb8','ze'],['za9','zb9','ze'],
['za10','zb10','ze']]
,index=[1,2,3,4,5,6,7,8,9,10],columns=['a','b','c'])
return DF
def get_DF_s1_2_s2(DF1,colmn_name,s1,s2):
a=DF1.reset_index().query('{}==@s1'.format(colmn_name)).index[0]
b=DF1.reset_index().query('{}==@s2'.format(colmn_name)).index[0]
DF2=DF1.iloc[a:b+1,:]
return DF2
def get_DF_S1(DF1,colmn_name,s1):
a=list(DF1.reset_index().query('{}==@s1'.format(colmn_name)).index)
DF2=DF1.iloc[a[0]:a[-1]+1,:]
return DF2
def get_Series_string(DF1,s1):
S1=DF1[s1]
return S1