pygenutils 16.2.0__tar.gz → 16.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pygenutils-16.2.0/pygenutils.egg-info → pygenutils-16.2.2}/PKG-INFO +1 -1
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/__init__.py +1 -1
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/arrays_and_lists/data_manipulation.py +3 -1
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/time_formatters.py +132 -70
- {pygenutils-16.2.0 → pygenutils-16.2.2/pygenutils.egg-info}/PKG-INFO +1 -1
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pyproject.toml +1 -1
- {pygenutils-16.2.0 → pygenutils-16.2.2}/LICENSE +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/MANIFEST.in +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/README.md +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/arrays_and_lists/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/arrays_and_lists/conversions.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/arrays_and_lists/maths.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/arrays_and_lists/patterns.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/audio_and_video_manipulation.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/merge_audio_and_video.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/merge_audio_or_video.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/trim_media.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/dictionaries/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/dictionaries/dict_handler.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/dictionaries/dict_operators.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/number_bases/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/number_bases/base_converters.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/number_bases/binary_operations.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/number_bases/bitwise_operators.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/number_bases/mathematical_utils.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/operative_systems/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/operative_systems/os_operations.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/sets_and_intervals/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/sets_and_intervals/interval_handler.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/sets_and_intervals/sets_handler.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/strings/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/strings/string_handler.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/strings/text_formatters.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/__init__.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/calendar_utils.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/countdown.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/date_and_time_maths.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/date_and_time_utils.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/program_snippet_exec_timers.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/time_utils.py +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils.egg-info/SOURCES.txt +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils.egg-info/dependency_links.txt +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils.egg-info/requires.txt +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils.egg-info/top_level.txt +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/setup.cfg +0 -0
- {pygenutils-16.2.0 → pygenutils-16.2.2}/setup.py +0 -0
|
@@ -600,7 +600,9 @@ def extract_1d_unique_basic(arr, procedure="dict", sort=False, reverse=False):
|
|
|
600
600
|
|
|
601
601
|
elif procedure == "list":
|
|
602
602
|
unique_val_arr = []
|
|
603
|
-
|
|
603
|
+
for num in arr:
|
|
604
|
+
if num not in unique_val_arr:
|
|
605
|
+
unique_val_arr.append(num)
|
|
604
606
|
|
|
605
607
|
elif procedure == "set":
|
|
606
608
|
unique_val_arr = list(set(arr))
|
|
@@ -147,7 +147,7 @@ def _arrow_get_with_import(*args, **kwargs):
|
|
|
147
147
|
# Input format: str #
|
|
148
148
|
#-------------------#
|
|
149
149
|
|
|
150
|
-
def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns"):
|
|
150
|
+
def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns", dayfirst=False, yearfirst=False):
|
|
151
151
|
"""
|
|
152
152
|
Convert a time string or object to a date/time object using a specified library.
|
|
153
153
|
|
|
@@ -181,6 +181,15 @@ def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns")
|
|
|
181
181
|
and 'us' for NumPy.
|
|
182
182
|
Then, in order to maintain compatibility, the largest common time unit 'us'
|
|
183
183
|
has been defined as default in this function.
|
|
184
|
+
dayfirst : bool, default False
|
|
185
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
186
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
187
|
+
Only applies when module is 'pandas'.
|
|
188
|
+
yearfirst : bool, default False
|
|
189
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
190
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
191
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
192
|
+
Only applies when module is 'pandas'.
|
|
184
193
|
|
|
185
194
|
Returns
|
|
186
195
|
-------
|
|
@@ -215,13 +224,13 @@ def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns")
|
|
|
215
224
|
if module == "pandas":
|
|
216
225
|
# If datetime_str is a string and looks like a numeric timestamp, use unit
|
|
217
226
|
if isinstance(datetime_str, str) and (datetime_str.isdigit() or (datetime_str.replace('.', '', 1).isdigit() and datetime_str.count('.') <= 1)):
|
|
218
|
-
datetime_obj = pd.to_datetime(datetime_str, unit=unit)
|
|
227
|
+
datetime_obj = pd.to_datetime(datetime_str, unit=unit, dayfirst=dayfirst, yearfirst=yearfirst)
|
|
219
228
|
else:
|
|
220
229
|
# Otherwise use format if provided, or let pandas infer the format
|
|
221
230
|
if dt_fmt_str is None:
|
|
222
|
-
datetime_obj = pd.to_datetime(datetime_str)
|
|
231
|
+
datetime_obj = pd.to_datetime(datetime_str, dayfirst=dayfirst, yearfirst=yearfirst)
|
|
223
232
|
else:
|
|
224
|
-
datetime_obj = parse_func(datetime_str, dt_fmt_str, unit)
|
|
233
|
+
datetime_obj = parse_func(datetime_str, dt_fmt_str, unit, dayfirst, yearfirst)
|
|
225
234
|
else:
|
|
226
235
|
# For other modules, use the parse_func as defined
|
|
227
236
|
datetime_obj = parse_func(datetime_str, dt_fmt_str, unit) if module == "numpy" else parse_func(datetime_str, dt_fmt_str)
|
|
@@ -243,7 +252,9 @@ def parse_float_dt(datetime_float,
|
|
|
243
252
|
origin="unix",
|
|
244
253
|
unit="us",
|
|
245
254
|
dt_fmt_str=None,
|
|
246
|
-
module="datetime"
|
|
255
|
+
module="datetime",
|
|
256
|
+
dayfirst=False,
|
|
257
|
+
yearfirst=False):
|
|
247
258
|
"""
|
|
248
259
|
Converts an integer or float time to a date/time object.
|
|
249
260
|
It also converts to a string representation if requested.
|
|
@@ -275,6 +286,15 @@ def parse_float_dt(datetime_float,
|
|
|
275
286
|
module : {"datetime", "time", "pandas", "numpy", "arrow", "str"}, default 'datetime'.
|
|
276
287
|
The module or class used to parse the floated time.
|
|
277
288
|
If 'numpy', datetime_float represents an offset from the Unix epoch start.
|
|
289
|
+
dayfirst : bool, default False
|
|
290
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
291
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
292
|
+
Only applies when module is 'pandas'.
|
|
293
|
+
yearfirst : bool, default False
|
|
294
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
295
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
296
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
297
|
+
Only applies when module is 'pandas'.
|
|
278
298
|
|
|
279
299
|
Returns
|
|
280
300
|
-------
|
|
@@ -313,9 +333,11 @@ def parse_float_dt(datetime_float,
|
|
|
313
333
|
origin,
|
|
314
334
|
dt_fmt_str,
|
|
315
335
|
unit,
|
|
316
|
-
module
|
|
336
|
+
module,
|
|
337
|
+
dayfirst,
|
|
338
|
+
yearfirst)
|
|
317
339
|
else:
|
|
318
|
-
return _float_dt_parser(datetime_float, module, unit)
|
|
340
|
+
return _float_dt_parser(datetime_float, module, unit, dayfirst, yearfirst)
|
|
319
341
|
|
|
320
342
|
|
|
321
343
|
# Auxiliary functions #
|
|
@@ -326,7 +348,9 @@ def _parse_float_to_string(floated_time,
|
|
|
326
348
|
origin,
|
|
327
349
|
dt_fmt_str,
|
|
328
350
|
unit,
|
|
329
|
-
module
|
|
351
|
+
module,
|
|
352
|
+
dayfirst,
|
|
353
|
+
yearfirst):
|
|
330
354
|
"""
|
|
331
355
|
Converts a floated time to its string representation.
|
|
332
356
|
|
|
@@ -345,6 +369,15 @@ def _parse_float_to_string(floated_time,
|
|
|
345
369
|
Time unit for `floated_time` if `origin='unix'` and `module` in {'numpy', 'pandas'}.
|
|
346
370
|
module : {"datetime", "time", "pandas", "numpy", "arrow"}
|
|
347
371
|
Module used for parsing.
|
|
372
|
+
dayfirst : bool, default False
|
|
373
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
374
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
375
|
+
Only applies when module is 'pandas'.
|
|
376
|
+
yearfirst : bool, default False
|
|
377
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
378
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
379
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
380
|
+
Only applies when module is 'pandas'.
|
|
348
381
|
|
|
349
382
|
Returns
|
|
350
383
|
-------
|
|
@@ -360,18 +393,18 @@ def _parse_float_to_string(floated_time,
|
|
|
360
393
|
if frac_precision is not None:
|
|
361
394
|
if frac_precision <= 6:
|
|
362
395
|
dt_seconds = round(floated_time)
|
|
363
|
-
dt_obj = _float_dt_parser(dt_seconds, module, unit)
|
|
396
|
+
dt_obj = _float_dt_parser(dt_seconds, module, unit, dayfirst, yearfirst)
|
|
364
397
|
dt_str = dt_obj.strftime(dt_fmt_str)
|
|
365
398
|
elif 7 <= frac_precision <= 9:
|
|
366
399
|
return get_nano_datetime(floated_time, module)
|
|
367
400
|
# Keep the original precision #
|
|
368
401
|
else:
|
|
369
|
-
dt_str = _float_dt_parser(floated_time, module, unit).strftime(dt_fmt_str)
|
|
402
|
+
dt_str = _float_dt_parser(floated_time, module, unit, dayfirst, yearfirst).strftime(dt_fmt_str)
|
|
370
403
|
|
|
371
404
|
return dt_str
|
|
372
405
|
|
|
373
406
|
|
|
374
|
-
def _float_dt_parser(floated_time, module, unit):
|
|
407
|
+
def _float_dt_parser(floated_time, module, unit, dayfirst, yearfirst):
|
|
375
408
|
"""
|
|
376
409
|
Parses a floated time into a date/time object.
|
|
377
410
|
|
|
@@ -383,6 +416,15 @@ def _float_dt_parser(floated_time, module, unit):
|
|
|
383
416
|
Module used for parsing.
|
|
384
417
|
unit : str, optional
|
|
385
418
|
Time unit for `floated_time` if `module` in {'numpy', 'pandas'}.
|
|
419
|
+
dayfirst : bool, default False
|
|
420
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
421
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
422
|
+
Only applies when module is 'pandas'.
|
|
423
|
+
yearfirst : bool, default False
|
|
424
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
425
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
426
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
427
|
+
Only applies when module is 'pandas'.
|
|
386
428
|
|
|
387
429
|
Returns
|
|
388
430
|
-------
|
|
@@ -403,7 +445,7 @@ def _float_dt_parser(floated_time, module, unit):
|
|
|
403
445
|
# Calculate datetime object #
|
|
404
446
|
#############################
|
|
405
447
|
|
|
406
|
-
datetime_obj = FLOATED_TIME_PARSING_DICT.get(module)(floated_time, unit)
|
|
448
|
+
datetime_obj = FLOATED_TIME_PARSING_DICT.get(module)(floated_time, unit, dayfirst, yearfirst)
|
|
407
449
|
return datetime_obj
|
|
408
450
|
|
|
409
451
|
|
|
@@ -482,7 +524,9 @@ def dt_obj_converter(datetime_obj,
|
|
|
482
524
|
unit="s",
|
|
483
525
|
float_class="d",
|
|
484
526
|
int_class="int",
|
|
485
|
-
dt_fmt_str=None
|
|
527
|
+
dt_fmt_str=None,
|
|
528
|
+
dayfirst=False,
|
|
529
|
+
yearfirst=False):
|
|
486
530
|
|
|
487
531
|
"""
|
|
488
532
|
Convert a date/time object to another, including float and string representation.
|
|
@@ -514,6 +558,15 @@ def dt_obj_converter(datetime_obj,
|
|
|
514
558
|
The integer precision class. Default is `"int"` (signed integer type).
|
|
515
559
|
dt_fmt_str : str
|
|
516
560
|
Format string to convert the date/time object to a string.
|
|
561
|
+
dayfirst : bool, default False
|
|
562
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
563
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
564
|
+
Only applies when converting to pandas objects.
|
|
565
|
+
yearfirst : bool, default False
|
|
566
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
567
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
568
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
569
|
+
Only applies when converting to pandas objects.
|
|
517
570
|
|
|
518
571
|
Returns
|
|
519
572
|
-------
|
|
@@ -587,7 +640,7 @@ def dt_obj_converter(datetime_obj,
|
|
|
587
640
|
conversion_dict = CONVERSION_OPT_DICT[obj_type]
|
|
588
641
|
return perform_conversion(conversion_dict, datetime_obj, unit=unit,
|
|
589
642
|
float_class=float_class, int_class=int_class,
|
|
590
|
-
dt_fmt_str=dt_fmt_str)
|
|
643
|
+
dt_fmt_str=dt_fmt_str, dayfirst=dayfirst, yearfirst=yearfirst)
|
|
591
644
|
|
|
592
645
|
|
|
593
646
|
# Auxiliary functions #
|
|
@@ -597,7 +650,7 @@ def dt_obj_converter(datetime_obj,
|
|
|
597
650
|
#-#-#-#-#-#-#-#-#-#-#-#-#-
|
|
598
651
|
|
|
599
652
|
# Scalar complex data #
|
|
600
|
-
def _total_dt_unit(datetime_obj, unit, float_class, int_class):
|
|
653
|
+
def _total_dt_unit(datetime_obj, unit, float_class=None, int_class=None):
|
|
601
654
|
"""
|
|
602
655
|
Convert a datetime object into total time based on the specified unit
|
|
603
656
|
(e.g., seconds, microseconds, nanoseconds).
|
|
@@ -784,7 +837,7 @@ def _to_string(dt_obj, unit, dt_fmt_str):
|
|
|
784
837
|
return str(dt_obj)
|
|
785
838
|
|
|
786
839
|
|
|
787
|
-
def _to_float(dt_obj, unit, float_class):
|
|
840
|
+
def _to_float(dt_obj, unit=None, float_class=None):
|
|
788
841
|
"""
|
|
789
842
|
Convert a datetime object to a float representing the total time in the specified unit.
|
|
790
843
|
|
|
@@ -804,7 +857,7 @@ def _to_float(dt_obj, unit, float_class):
|
|
|
804
857
|
"""
|
|
805
858
|
obj_type = get_type_str(dt_obj, lowercase=True)
|
|
806
859
|
if obj_type == "datetime64":
|
|
807
|
-
return dt_obj.astype(f"timedelta64[{unit}]").astype(float_class)
|
|
860
|
+
return dt_obj.astype(f"timedelta64[{unit}]").astype(float_class) if unit and float_class else dt_obj.astype(float)
|
|
808
861
|
elif obj_type == "time": # datetime.time
|
|
809
862
|
return __time_component_to_float(dt_obj)
|
|
810
863
|
if hasattr(dt_obj, 'timestamp'):
|
|
@@ -833,7 +886,7 @@ def __time_component_to_float(t):
|
|
|
833
886
|
return time_component_float
|
|
834
887
|
|
|
835
888
|
|
|
836
|
-
def _to_datetime(dt_obj, unit):
|
|
889
|
+
def _to_datetime(dt_obj, unit=None):
|
|
837
890
|
"""
|
|
838
891
|
Convert a given datetime-like object or each value in DataFrame/Series to a
|
|
839
892
|
standard Python datetime object.
|
|
@@ -873,7 +926,7 @@ def _to_datetime(dt_obj, unit):
|
|
|
873
926
|
else:
|
|
874
927
|
if obj_type == "datetime64":
|
|
875
928
|
# If unit is 'ns' (nanoseconds), use the auxiliary conversion function
|
|
876
|
-
unit = get_datetime_object_unit(dt_obj)
|
|
929
|
+
unit = unit or get_datetime_object_unit(dt_obj)
|
|
877
930
|
if unit == "ns":
|
|
878
931
|
return _to_datetime_aux(dt_obj, unit)
|
|
879
932
|
else:
|
|
@@ -904,7 +957,7 @@ def _to_datetime_aux(dt_obj, unit):
|
|
|
904
957
|
return pd.to_datetime(dt_obj, unit=unit).to_pydatetime()
|
|
905
958
|
|
|
906
959
|
|
|
907
|
-
def _to_time_struct(dt_obj):
|
|
960
|
+
def _to_time_struct(dt_obj, unit=None):
|
|
908
961
|
"""
|
|
909
962
|
Convert a datetime-like object to a time.struct_time object.
|
|
910
963
|
|
|
@@ -912,15 +965,17 @@ def _to_time_struct(dt_obj):
|
|
|
912
965
|
----------
|
|
913
966
|
dt_obj : datetime-like
|
|
914
967
|
The object to be converted to time.struct_time.
|
|
968
|
+
unit : str, optional
|
|
969
|
+
The unit for conversion (if needed).
|
|
915
970
|
|
|
916
971
|
Returns
|
|
917
972
|
-------
|
|
918
973
|
time.struct_time
|
|
919
974
|
The converted time.struct_time object.
|
|
920
975
|
"""
|
|
921
|
-
return _to_datetime(dt_obj).timetuple()
|
|
976
|
+
return _to_datetime(dt_obj, unit).timetuple()
|
|
922
977
|
|
|
923
|
-
def _to_pandas(dt_obj, unit):
|
|
978
|
+
def _to_pandas(dt_obj, unit, dayfirst=False, yearfirst=False):
|
|
924
979
|
"""
|
|
925
980
|
Convert a datetime-like object to a pandas Timestamp object with the specified unit.
|
|
926
981
|
|
|
@@ -930,15 +985,22 @@ def _to_pandas(dt_obj, unit):
|
|
|
930
985
|
The object to be converted to a pandas Timestamp.
|
|
931
986
|
unit : str, optional
|
|
932
987
|
The unit for conversion.
|
|
988
|
+
dayfirst : bool, default False
|
|
989
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
990
|
+
If True, parses dates with the day first, e.g. "10/11/12" is parsed as 2012-11-10.
|
|
991
|
+
yearfirst : bool, default False
|
|
992
|
+
Specify a date parse order if datetime_str is str or is list-like.
|
|
993
|
+
If True parses dates with the year first, e.g. "10/11/12" is parsed as 2010-11-12.
|
|
994
|
+
If both dayfirst and yearfirst are True, yearfirst is preceded (same as dateutil).
|
|
933
995
|
|
|
934
996
|
Returns
|
|
935
997
|
-------
|
|
936
998
|
pd.Timestamp
|
|
937
999
|
The converted pandas Timestamp object.
|
|
938
1000
|
"""
|
|
939
|
-
return pd.to_datetime(_to_datetime(dt_obj), unit=unit)
|
|
1001
|
+
return pd.to_datetime(_to_datetime(dt_obj), unit=unit, dayfirst=dayfirst, yearfirst=yearfirst)
|
|
940
1002
|
|
|
941
|
-
def _to_numpy(dt_obj, unit):
|
|
1003
|
+
def _to_numpy(dt_obj, unit=None):
|
|
942
1004
|
"""
|
|
943
1005
|
Convert a datetime-like object to a NumPy datetime64 object with the specified unit.
|
|
944
1006
|
|
|
@@ -954,7 +1016,7 @@ def _to_numpy(dt_obj, unit):
|
|
|
954
1016
|
np.datetime64
|
|
955
1017
|
The converted NumPy datetime64 object.
|
|
956
1018
|
"""
|
|
957
|
-
dt_obj = _to_datetime(dt_obj)
|
|
1019
|
+
dt_obj = _to_datetime(dt_obj, unit)
|
|
958
1020
|
return np.datetime64(_tzinfo_remover(dt_obj), unit)
|
|
959
1021
|
|
|
960
1022
|
def _to_arrow(dt_obj):
|
|
@@ -998,7 +1060,7 @@ _INT_CLASS_LIST = [np.int8, np.int16, "i", np.float32, "int", np.int64]
|
|
|
998
1060
|
TIME_STR_PARSING_DICT = {
|
|
999
1061
|
"datetime" : lambda datetime_str, dt_fmt_str: datetime.strptime(datetime_str, dt_fmt_str),
|
|
1000
1062
|
"dateutil" : lambda datetime_str, dt_fmt_str: parser.parse(datetime_str, dt_fmt_str),
|
|
1001
|
-
"pandas" : lambda datetime_str, dt_fmt_str,
|
|
1063
|
+
"pandas" : lambda datetime_str, dt_fmt_str, unit, dayfirst=False, yearfirst=False : pd.to_datetime(datetime_str, format=dt_fmt_str, dayfirst=dayfirst, yearfirst=yearfirst),
|
|
1002
1064
|
"numpy" : lambda datetime_str, _, unit : np.datetime64(datetime_str, unit),
|
|
1003
1065
|
"arrow" : lambda datetime_str, dt_fmt_str: _arrow_get_with_import(datetime_str, dt_fmt_str)
|
|
1004
1066
|
}
|
|
@@ -1007,11 +1069,11 @@ TIME_STR_PARSING_DICT = {
|
|
|
1007
1069
|
#-#-#-#-#-#
|
|
1008
1070
|
|
|
1009
1071
|
FLOATED_TIME_PARSING_DICT = {
|
|
1010
|
-
"datetime" : lambda floated_time,
|
|
1011
|
-
"time" : lambda floated_time : datetime(*tuple(time.localtime(floated_time))[:6]),
|
|
1012
|
-
"pandas" : lambda floated_time, unit : pd.to_datetime(floated_time, unit=unit),
|
|
1013
|
-
"numpy" : lambda floated_time, unit : np.datetime64(floated_time, unit),
|
|
1014
|
-
"arrow" : lambda floated_time,
|
|
1072
|
+
"datetime" : lambda floated_time, unit, dayfirst=False, yearfirst=False : datetime.fromtimestamp(floated_time),
|
|
1073
|
+
"time" : lambda floated_time, unit, dayfirst=False, yearfirst=False : datetime(*tuple(time.localtime(floated_time))[:6]),
|
|
1074
|
+
"pandas" : lambda floated_time, unit, dayfirst=False, yearfirst=False : pd.to_datetime(floated_time, unit=unit, dayfirst=dayfirst, yearfirst=yearfirst),
|
|
1075
|
+
"numpy" : lambda floated_time, unit, dayfirst=False, yearfirst=False : np.datetime64(floated_time, unit),
|
|
1076
|
+
"arrow" : lambda floated_time, unit, dayfirst=False, yearfirst=False : _arrow_get_with_import(floated_time)
|
|
1015
1077
|
}
|
|
1016
1078
|
|
|
1017
1079
|
# Complex data #
|
|
@@ -1019,63 +1081,63 @@ FLOATED_TIME_PARSING_DICT = {
|
|
|
1019
1081
|
|
|
1020
1082
|
# To other objects #
|
|
1021
1083
|
DT_OBJ_CONVERSION_DICT = {
|
|
1022
|
-
"float" : lambda dt_obj,
|
|
1023
|
-
"time" : lambda dt_obj,
|
|
1024
|
-
"pandas" : lambda dt_obj, unit,
|
|
1025
|
-
"numpy" : lambda dt_obj, unit,
|
|
1026
|
-
"arrow" : lambda dt_obj,
|
|
1027
|
-
"str" : lambda dt_obj,
|
|
1084
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.timestamp(),
|
|
1085
|
+
"time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.timetuple(),
|
|
1086
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(_tzinfo_remover(dt_obj), unit, dayfirst, yearfirst),
|
|
1087
|
+
"numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(_tzinfo_remover(dt_obj), unit),
|
|
1088
|
+
"arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
|
|
1089
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
|
|
1028
1090
|
}
|
|
1029
1091
|
|
|
1030
1092
|
DT64_OBJ_CONVERSION_DICT = {
|
|
1031
|
-
"float" : lambda dt_obj, unit,
|
|
1032
|
-
"datetime" : lambda dt_obj, unit : _to_datetime(dt_obj, unit),
|
|
1033
|
-
"time" : lambda dt_obj,
|
|
1034
|
-
"pandas" : lambda dt_obj, unit : _to_pandas(dt_obj, unit),
|
|
1035
|
-
"arrow" : lambda dt_obj,
|
|
1036
|
-
"str" : lambda dt_obj,
|
|
1093
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
|
|
1094
|
+
"datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1095
|
+
"time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
|
|
1096
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
|
|
1097
|
+
"arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
|
|
1098
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(_to_datetime(dt_obj), unit, dt_fmt_str)
|
|
1037
1099
|
}
|
|
1038
1100
|
|
|
1039
1101
|
DT_TIME_OBJ_CONVERSION_DICT = {
|
|
1040
|
-
"float" : lambda dt_obj,
|
|
1041
|
-
"datetime" : lambda dt_obj,
|
|
1042
|
-
"time" : lambda dt_obj,
|
|
1043
|
-
"pandas" : lambda dt_obj,
|
|
1044
|
-
"numpy" : lambda dt_obj,
|
|
1045
|
-
"arrow" : lambda dt_obj,
|
|
1046
|
-
"str" : lambda dt_obj,
|
|
1102
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
|
|
1103
|
+
"datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1104
|
+
"time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
|
|
1105
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(_to_datetime(dt_obj), unit, dayfirst, yearfirst),
|
|
1106
|
+
"numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(_to_datetime(dt_obj), unit),
|
|
1107
|
+
"arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
|
|
1108
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
|
|
1047
1109
|
}
|
|
1048
1110
|
|
|
1049
1111
|
TIMESTAMP_OBJ_CONVERSION_DICT = {
|
|
1050
|
-
"float" : lambda dt_obj,
|
|
1051
|
-
"datetime" : lambda dt_obj, unit,
|
|
1052
|
-
"time" : lambda dt_obj,
|
|
1053
|
-
"numpy" : lambda dt_obj,
|
|
1054
|
-
"arrow" : lambda dt_obj,
|
|
1055
|
-
"str" : lambda dt_obj,
|
|
1112
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
|
|
1113
|
+
"datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1114
|
+
"time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
|
|
1115
|
+
"numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.to_numpy(),
|
|
1116
|
+
"arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
|
|
1117
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
|
|
1056
1118
|
}
|
|
1057
1119
|
|
|
1058
1120
|
ARROW_OBJ_CONVERSION_DICT = {
|
|
1059
|
-
"float" : lambda dt_obj,
|
|
1060
|
-
"datetime" : lambda dt_obj, unit : _to_datetime(dt_obj, unit),
|
|
1061
|
-
"time" : lambda dt_obj,
|
|
1062
|
-
"pandas" : lambda dt_obj, unit,
|
|
1063
|
-
"numpy" : lambda dt_obj, unit,
|
|
1064
|
-
"str" : lambda dt_obj,
|
|
1121
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
|
|
1122
|
+
"datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1123
|
+
"time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
|
|
1124
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
|
|
1125
|
+
"numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(dt_obj, unit),
|
|
1126
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
|
|
1065
1127
|
}
|
|
1066
1128
|
|
|
1067
1129
|
TIME_STT_OBJ_CONVERSION_DICT = {
|
|
1068
|
-
"float" : lambda dt_obj,
|
|
1069
|
-
"datetime" : lambda dt_obj, unit : _to_datetime(dt_obj, unit),
|
|
1070
|
-
"pandas" : lambda dt_obj, unit : pd.Timestamp(*dt_obj[:6], unit=unit),
|
|
1071
|
-
"numpy" : lambda dt_obj, unit : np.datetime64(datetime(*dt_obj[:6]), unit),
|
|
1072
|
-
"arrow" : lambda dt_obj,
|
|
1130
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
|
|
1131
|
+
"datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1132
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : pd.Timestamp(*dt_obj[:6], unit=unit),
|
|
1133
|
+
"numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : np.datetime64(datetime(*dt_obj[:6]), unit),
|
|
1134
|
+
"arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
|
|
1073
1135
|
}
|
|
1074
1136
|
|
|
1075
1137
|
_DT_LIKE_OBJ_CONVERSION_DICT = {
|
|
1076
|
-
"float" : lambda dt_obj, unit,
|
|
1077
|
-
"pandas" : lambda dt_obj, unit,
|
|
1078
|
-
"str" : lambda dt_obj, unit, dt_fmt_str : _to_string(dt_obj,
|
|
1138
|
+
"float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _total_dt_unit(dt_obj, unit, float_class, int_class),
|
|
1139
|
+
"pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
|
|
1140
|
+
"str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
|
|
1079
1141
|
}
|
|
1080
1142
|
|
|
1081
1143
|
# Enumerate all possibilities #
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygenutils"
|
|
7
|
-
version = "16.2.
|
|
7
|
+
version = "16.2.2"
|
|
8
8
|
license = {file = "LICENSE"}
|
|
9
9
|
description = "A comprehensive Python utility library for general-purpose and specialised tasks"
|
|
10
10
|
keywords = ["utilities", "python", "general-purpose", "file handling", "string processing"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/audio_and_video/audio_and_video_manipulation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pygenutils-16.2.0 → pygenutils-16.2.2}/pygenutils/time_handling/program_snippet_exec_timers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|