2000 Ford Escort Rough Idle CEL

I have a 2000 2.0L split injection v4 Ford Escort with 71000 miles.
About a month ago I noticed the idle was getting a little rough. However,
the roughness does not begin immeadiately when I stop the car. It takes 20-40 seconds before it starts. The roughness could be described as a cycling where it appears the rpms drop and the engine "coughs" and then it gets better for a second before cycling down again. If I don't give the engine gas it will stall about 30 seconds after the rough idle begins.
When I am driving at any speed, or even giving it gas in neutral, the problem does not exist. I recently replaced the air filter and the problem did not improve.
Additionally, I have experienced a decrease in gas milage of 5-8 mpg.
The check engine light came on about a week after the rough idle started. It stays on constantly. I took the car to autozone for a free code check, and it returned the code: 171 which is left bank lean.
The guy at auto zone said my O2 sensor is probably bad and quickly offered to sell me one. Is he likely correct? I have the Haynes repair manual and would like to try and fix this myself.
Thanks for any help!
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file

Motorsforum.com is a website by car enthusiasts for car enthusiasts. It is not affiliated with any of the car or spare part manufacturers or car dealers discussed here. All logos and trade names are the property of their respective owners.