Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python weekly aggreation string time

from collections import defaultdict
from datetime import datetime as dt
curr = '2019-01-01'
idx = 0
dic = defaultdict(list)
for i in ts:
 if ( dt.strptime(i, '%Y-%m-%d') -  dt.strptime(curr, '%Y-%m-%d')).days < 7 :
     dic[idx].append(i)
 else:
    curr = i
    idx += 1
    dic[idx].append(i)
print(dic.values())
Comment

PREVIOUS NEXT
Code Example
Python :: extended slices [::2] 
Python :: how to make a new df from old 
Python :: pairplot lower triangular 
Python :: overlay bar plot and line plot in python 
Python :: collecion.alt shopify python 
Python :: Data type based on rows 
Python :: WS2812 Thonny microPython 
Python :: Pyturch training along with source code 
Python :: auto reload exml odoo 13 
Python :: Square Odd Python 
Python :: link prettify in beautifulsoup 
Python :: Python return statement (Write and Call Function) 
Python :: split x and y pandas 
Python :: write console output in same place 
Python :: how to get mid time of given time in python 
Python :: selenium emojis 
Python :: automate ms word with python 
Python :: list update python 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: else 
Python :: python generate string of length 
Python :: create game board with radone values within a range python 
Python :: How can I Duplicate 1 Dimensional array 
Python :: python __truediv__ 
Python :: python mxs Classof 
Python :: NumPy invert Code When the input is an array 
Python :: qt list widget let editable 
Python :: penggunaan len di python 
Python :: python special methods list 
Python :: python how to convert each word of each row to numeric value of a dataframe 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =