我有两个需要映射的数据帧,最终输出应该是这样的。
输入1
LPAR DC
A LA
B NY
C CT
D VA
E WO
输入2
LPAR PROD
A Microsoft
A Symantec
A Vmware
B Compuware
C BMC
B CA
最终输出
LPAR DC PROD
A LA Microsoft
A LA Symantec
A LA Vmware
B NY Compuware
B NY CA
C CT BMC
D VA
E WO
答案 0 :(得分:1)
您可fillna
两个DataFrames和dict1 = {'LPAR': ['A', 'B', 'C', 'D', 'E'],
'DC': ['LA', 'NY', 'CT', 'VA', 'WO']}
df1 = pd.DataFrame(dict1)
dict2 = {'LPAR': ['A', 'A', 'A', 'B', 'B', 'C'],
'PROD': ['Microsoft', 'Symantec', 'Vmware', 'Compuware', 'CA', 'BMC']}
df2 = pd.DataFrame(dict2)
df3 = df1.merge(df2, on='LPAR', how='outer').fillna('')
空字符串
Select t.*
from Table t
Where (Start_time <= End_time and MyTime >= Start_Time and MyTime < End_Time) or
(Start_time > End_time and MyTime < Start_Time and MyTime >= End_Time);