You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
472 B
Python
17 lines
472 B
Python
# -*- coding: utf-8 -*-
|
|
# @Time : 2023/5/24 15:23
|
|
# @Author : zhaoxiangpeng
|
|
# @File : change_head.py
|
|
|
|
import pandas as pd
|
|
from typing import Union
|
|
|
|
|
|
def rename_head(table_or_head: Union[pd.DataFrame, list], postfix: str = '-other') -> dict:
|
|
if isinstance(table_or_head, pd.DataFrame):
|
|
table_or_head = table_or_head.columns.values.tolist()
|
|
new_head = {}
|
|
for head in table_or_head:
|
|
new_head[head] = str(head) + postfix
|
|
return new_head
|