我想我的DF值映射到一個字符串大熊貓DF:使用地圖
SQL = """select * from mytable where col1={0} and col2={1}"""
我想這ListResult = map(lambda x :SQL.format(*x),DF[['Col1','Col2']])
但輸出像
[u'select * from mytable where col1 = C and col2=o',
u'select * from mytable where col1 = C and col2=o']
怎樣才能用我DF的值填充的字符串列表(列的數量可能因SQL而異)?
編輯:加樣品及預期的結果
> DF =
- Col1 Col2
- 0 1591354166 12387796
- 1 1596855166 8833942
- 2 1626196066 12584655
預期的結果:
[select * from mytable where col1=1591354166 and col2=12387796,
select * from mytable where col1=1596855166 and col2=8833942,
select * from mytable where col1=1626196066 and col2=12584655]
你可以添加[最小的,完整的和可驗證的示例](http://stackoverflow.com/help/mcve)或者至少是數據幀的樣本 - 3,4行和樣本的期望輸出? – jezrael
是的,我可以^^給我5分鐘 – Steven