I'm working on a program, and I need to group strings that are generated on a certain date.
The form of grouping that I want is to group the same chain every time it is repeated, as long as a next repetition occurs in less than 30 days. In the case that after 30 days it is repeated again (it is a mobile account).
Until now I am reading from a CSV and I have the strings separated and the dates converted into date, as follows:
import pandas as pd import numpy as np import numpy import csv from numpy import genfromtxt import numpy as np from datetime import datetime, timedelta from time import time df = pd.read_csv('Export.csv', header=0, sep=';') FDE= FDE=df["#"] +"-"+df["Text"] #Crear lista df[" Date"] = pd.to_datetime(df[" Date"]) #Convertir fechas a date print(FDE)
FDE is the chain that I should look for, whenever FDE is repeated and the date associated with the repeated FDE is less than 30 days, it should be counted. In cases where FDE is greater than 30 days, the count must be restarted. This way there are different stories for a type of FDE.
The file I'm reading about is the following:
Any idea or help is appreciated.
Example of output:
CCB-HYD PUPRI R = 2 CBH-G AIR = 2 CBD-FD AIL = 2 CBD-FFAIL = 2