import pandas as pd
import time
def makeurl(url,url_show):
    return '=HYPERLINK("{}","{}")'.format(url,  url_show)


def handle_df():
    df = pd.read_excel("./df_gmgn_pump_total.xlsx")
    df_temp = pd.read_excel("./df_gmgn_pump_total_temp.xlsx")
    df_temp = df_temp[~df_temp['token_url'].isin(df['token_url'])].reset_index(drop=True)
    df = pd.concat([df,df_temp])
      
    # df['datetime'] = pd.to_datetime(df['save_timestamp'],unit='ms' )

    df=df.sort_values(by=['datetime','token_url'],ascending=[True,True])
    df = df.drop_duplicates(subset=['token_url'],keep='first')
    
    # df['datetime'] =df['datetime'].dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai').dt.strftime('%Y-%m-%d %H:%M:%S')
    
    # df['token_add'] = df['token_url'].str.split('/').str[-1]
    
 
    df["gmgn"] = df.apply(lambda ser: makeurl(
    f"https://gmgn.ai/sol/token/{ser['token_add']}" , "gmgn" ), axis=1)

    df["defined"] = df.apply(lambda ser: makeurl(
     f"https://www.defined.fi/sol/{ser['token_add']}" , "defined" ), axis=1)
    # df["isnormal"] = None
    # df["beizhu"] = None
    df.to_excel(f"df_gmgn_pump_total_aa.xlsx",index=False)



handle_df()