<jupyter_start><jupyter_text><jupyter_code>import pandas as pd
from typing import List
from datetime import datetime
from random import randint
from dateutil.relativedelta import *

    factionName: List[str] = []
    systemName: List[str] = []
    population: List[int] = []
    influence: List[float] = []
    updated: List[datetime] = []
factionName: List[str] = []
systemName: List[str] = []
population: List[int] = []
influence: List[float] = []
updated: List[datetime] = []
    
randStrs = ['foo', 'bar', 'guh']

def randStr() -> str:
  global randStrs
  return randStrs[randint(0, len(randStrs))]

def seqStr(i: int) -> str:
  global randStrs
  return randStrs[i % len(randStrs)]

start_date = datetime.strptime("2020-06-01", "%Y-%m-%d")


for fac in ['foo','bar','guh']:
  upd = start_date
  for sys in ['sol','celeano']:
    for i in range(0,5):
      factionName.append( fac)
      systemName.append( sys)
      population.append(10000)
      influence.append(.33)

      day = randint(2,4)
      upd = upd + relativedelta(hours=day*8)
      updated.append(upd)


data = { 'systemName' : systemName,
         'factionName' : factionName,
         'population' : population,
         'influence'  : influence,
         'updated' : updated
        }
df = pd.DataFrame(data = data)

# prepare data

df['updated'] = df.updated.dt.round("D") 
df = df.sort_values(by=['systemName', 'factionName','updated'])

# this drops out all data that doesn't have at least 2 days in a row
systems = df['systemName'].unique().tolist()
holder = pd.DataFrame()

for sys in systems:
  print(sys)
  sysSlice = df[ df['systemName'] ==sys]
  facs = sysSlice['factionName'].unique().tolist()
  for fac in facs:
    print("\t"+ fac)
    facSlice = sysSlice[ sysSlice['factionName'] == fac].reset_index()
    facSlice['diff1'] = facSlice.updated.diff(periods=1).dt.days.abs()
    facSlice['diff2'] = facSlice.updated.diff(periods=-1).dt.days.abs()
    facSlice = facSlice.fillna(999.0) 
    facSlice['diffz'] = facSlice[['diff1','diff2']].min(axis=1)
    facSlice = facSlice[ facSlice['diffz'] <=1.0]
    facSlice = facSlice.drop(['diff1','diff2','diffz'],  axis=1)
    holder = holder.append(facSlice.copy(), ignore_index=True)


holder
def minAbs(x1: float, x2: float) -> float:
  return min ( abs(x1), abs(x2))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16766981943250214, 'fraction_numerical': 0.018056749785038694, 'mean_word_length': 3.8989473684210525, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '1772', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 852, 'n_tokens_neox': 822, 'n_words': 179, 'path': 'notebooks/ANN.ipynb', 'repo_name': 'HausReport/ClubRaiders', 'size': '2326'}