我有以下熊猫数据帧
Column1
Column1 Column2
10572 ORCHESTRA
18125 ORCHESTRA
21906 ORCHESTRA
22106 ORCHESTRA我想像这样在查询中赋值
AND
(colunm2 , column1) IN (
('ORCHESTRA', 18423),
('ORCHESTRA', 14931),
('ORCHESTRA', 12573),
('ORCHESTRA', 8849),非常感谢
发布于 2017-10-09 19:42:11
df['new_column'] = df['Column2'].astype(str) + df['Column1'].astype(str)
df = df[df['new_column'].isin(['ORCHESTRA18423', etc.])]发布于 2017-10-09 22:18:03
我不能理解你的问题,但也许它会对你有所帮助,
如果要从表中获取column1值,则为
和column1 in (从表中选择Column1 )和column2 in ('ORCHESTRA')
或
和column1 in (从表中选择Column1 )和column2 in (从表中选择Column2 )
如果要传递值,则为
和(18423,14931,12573,8849)中的column1和('ORCHESTRA')中的column2 )
https://stackoverflow.com/questions/46642844
复制相似问题