Example #1
0
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

from dateutil.relativedelta import relativedelta
from datetime import datetime
from datetime import timedelta
import time

weekSet = []

from src.logger_setting.my_logger import get_logger

logger = get_logger()


def get_week_day(date):
    week = datetime.strptime(date, "%Y%m%d").weekday()
    return week


def add_days(date, num):
    return (datetime.strptime(date, "%Y%m%d") +
            timedelta(days=num)).strftime("%Y%m%d")


def add_months(date, num):
    return (datetime.strptime(date, "%Y%m%d") +
            relativedelta(months=num)).strftime("%Y%m%d")
#  limitations under the License.

import os
import time
from typing import Dict, List

import numpy as np
import pandas as pd
from collections import Counter

from src.compress import compress
# 日志器
from src.logger_setting.my_logger import get_logger
from src.setting import setting

LOGGER = get_logger()


def groupby_calc(df):
    df['esn'] = df['esn'].astype('str')
    df = df.groupby(['esn'])
    return df


def calc_total(series):
    series = series.values
    count = 0
    for d in range(len(series)):
        if d < len(series) - 1:
            if pd.isna(series[d]) or pd.isna(series[d + 1]):
                continue