21 9 2020
import pandas as pd
from pandas import Series,DataFrame
import numpy as np

#读取本地数据
df = pd.read_excel('./2020-09-20.xlsx')


df['签订日期'] = pd.to_datetime(df['签订日期'])
df['起始日期'] = pd.to_datetime(df['起始日期'])
df['截止日期'] = pd.to_datetime(df['截止日期'])
df['金额'] = df['金额'].apply(lambda x: float(str(x).replace(",", "")))


#删除DataFrame里某一列有空值的行
df.dropna(subset=['存单状态', '年利率(%)', '金额', '起始日期', '截止日期'], inplace=True)

# 筛选数据
df.loc(df['xx']==0)


# 金额*利率*天数(计息截止日-计息起始日)/360
df['利息'] = df['金额'] * (df['年利率(%)']/100) * (df['截止日期'] - df['起始日期']).dt.days / 360
df.head(10)


# 保存
df.to_excel('./2020-09-20_finish.xlsx',index=False,encoding='utf-8')


from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait


def wait_element_exist(driver, element, timeout=5, raise_error=False):
    """

    :param driver:
    :param element:
    :param timeout:
    :param raise_error:
    :return:
    """
    status = False
    try:
        WebDriverWait(driver, timeout, 0.5).until(
            EC.presence_of_element_located((By.XPATH, element)))
        status = True
    except Exception as e:
        if raise_error:
            raise e
        print("[Error:wait_element_exist]", e)
        status = False
    return status


def wait_element_click(driver, element, timeout=5, raise_error=False):
    status = False
    try:
        WebDriverWait(driver, timeout, 0.5).until(EC.presence_of_element_located((By.XPATH, element)))
        driver.find_element_by_xpath(element).click()
        print('点击成功 {}'.format(element))
        status = True
    except Exception as e:
        if raise_error:
            raise e
        print("[Error:wait_click_element]:{},element={}".format(e, element))
        status = False
    return status


def wait_element_send(driver, element, value, timeout=5, raise_error=False):
    """

    :param driver:
    :param element:
    :param value:
    :param timeout:
    :return:
    """
    status = False
    try:
        WebDriverWait(driver, timeout, 0.5).until(EC.presence_of_element_located((By.XPATH, element)))
        driver.find_element_by_xpath(element).clear()
        driver.find_element_by_xpath(element).send_keys(str(value))
        status = True
    except Exception as e:
        if raise_error:
            raise e
        print("[Error:sendKeys]", e)
        status = False
    return status

-

 

延伸阅读
  • 阿良
    猛很,男人
    < /body> < /html>