#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pandas as pd
import json
import traceback


def status_mapping(mapping_file, status_df):
    try:
        with open(mapping_file, 'r') as file:
            status_mapping = json.load(file)

    except Exception as e:
        traceback.print_exc()
        return status_df

    # for status_column in status_df.columns:
    for status_column in status_mapping.keys():
        status_df[status_column] = status_df[status_column].astype(int).astype(str)
        status_df[status_column] = status_df[status_column].map(status_mapping[status_column])

    return status_df

if __name__ == '__main__':
    mapping_file = 'status.json'
    status_df = pd.read_csv('VehState.csv')
    ans = status_mapping(mapping_file, status_df)

    # 显示结果
    print(ans)
