파이썬
[python] df.drop if exists
필경이야
2022. 10. 13. 09:02
[python] df.drop if exists
hh = pd.DataFrame([{"1":1,"2":3},{"1":1,"2":3},{"1":1,"2":3},{"1":1,"2":3}])
ii = pd.DataFrame([{"1":1,"2":3},{"1":1,"2":3},{"1":1,"2":3},{"1":1,"2":3}])
test = pd.DataFrame([{"1":1,"2":3},{"1":1,"2":3}])
hh.drop(columns=["3"])
오류발생!
hh.drop(columns=["3"], errors='ignore')
## output
1 2
0 1 3
1 1 3
2 1 3
3 1 3
정상 진행!