Data in sample_train-item-views.csv use session_id& item_id as the column name . But the code in line 56 & 57 is like data['session_id'] = data.pop('sessionId') .This will lead to error when testing sample data. So the code should be modified as data['session_id'] = data.pop('session_id') and data['item_id'] = data.pop('item_id'). The error disappeared and the code produces sample txt file normally after this modification👍