zastap_cabin = { 'B51 B53 B55':'B51', 'B52 B54 B56':'B52', 'B57 B59 B63 B66':'B57', 'B58 B60':'B58', 'B82 B84':'B82', 'C22 C26':'C22', 'C23 C25 C27':'C23', 'C55 C57':'C55', 'C62 C64':'C62', 'D10 D12':'D10' } df['cabin'] = df['cabin'].replace(zastap_cabin)