import numpy as np
import pandas as pd
import random
import math

if __name__ == '__main__':
    # my_list = [8,3,6,7]
    # my_list.append(5)
    # arr = np.array(my_list)

    # k_sort = [2,3,4]

    # k_sort = np.take(arr, k_sort)

    # print(k_sort)

    # candidate = np.ones(5)
    # candidate[2] = 0
    # candidate[4] = 0
    # print(candidate)

    # k_sort = np.where(candidate == 1)[0]
    # print(k_sort)

    # 读取 CSV 文件，并指定第一行作为列名
    # data_map_file = "/data/dataset/femnist/client_data_mapping/train.csv"
    # df = pd.read_csv(data_map_file, delimiter=',', header=0)

    # # 将 client_id 列转换为整数类型
    # df['client_id'] = df['client_id'].astype(str).str.strip()  # 去除两端空格并转换为字符串类型
    # df['client_id'] = df['client_id'].astype(int)


    # client_id_counts = df['client_id'].value_counts().to_dict()

    # for client_id, count in client_id_counts.items():
    #     print(f"client_id为{client_id}的数据条数为: {count}")

    # print(client_id_counts.get(1928,0))



    # def adjust_with_tanh(values):
    #     adjusted_values = []
    #     for val in values:
    #         adjusted_val = (math.tanh(val) + 1) / 2
    #         adjusted_values.append(adjusted_val)
    #     return adjusted_values

    # def adjust_with_exponential(values):
    #     adjusted_values = []
    #     for val in values:
    #         adjusted_val = math.exp(val) / (1 + math.exp(val))
    #         adjusted_values.append(adjusted_val)
    #     return adjusted_values

    # # 原始数值
    # original_values = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]

    # # 使用tanh调整数值
    # adjusted_values_tanh = adjust_with_tanh(original_values)
    # print("使用tanh调整后的数值:", adjusted_values_tanh)

    # # 使用指数函数调整数值
    # adjusted_values_exponential = adjust_with_exponential(original_values)
    # print("使用指数函数调整后的数值:", adjusted_values_exponential)
    # b =  [[1,2], [3,4], [6,7],[5,2],[3,20],[3,4]]
    # b = np.array(b)
    # top_k = np.argsort(b[:,1])[-4:]
    # print(top_k)
    # a = np.array([1,2])
    # print(a[0])
    # c = a[0]
    # print(c[0])

