我有以下pandas dataframe
列1
Column1 Column2
10572 ORCHESTRA
18125 ORCHESTRA
21906 ORCHESTRA
22106 ORCHESTRA
我想在这个查询中加入值
AND
(colunm2 , column1) IN (
('ORCHESTRA', 18423),
('ORCHESTRA', 14931),
('ORCHESTRA', 12573),
('ORCHESTRA', 8849),
非常感谢
答案 0 :(得分:0)
df['new_column'] = df['Column2'].astype(str) + df['Column1'].astype(str)
df = df[df['new_column'].isin(['ORCHESTRA18423', etc.])]
答案 1 :(得分:0)
我无法理解您的问题,但可能对您有所帮助,
如果您想从表
中获取column1值AND column1 in(从yourtable中选择Column1) AND列2(' ORCHESTRA')
或
AND column1 in(从yourtable中选择Column1) AND column2 in(从yourtable中选择Column2)
如果您想传递值
AND column1 in(18423,14931,12573,8849) AND列2(' ORCHESTRA')