imsciences 0.6.0.7__tar.gz → 0.6.0.8__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.
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/PKG-INFO +1 -1
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences/datafunctions.py +11 -12
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences.egg-info/PKG-INFO +1 -1
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/setup.py +1 -1
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/README.md +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences/__init__.py +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences.egg-info/SOURCES.txt +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences.egg-info/dependency_links.txt +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences.egg-info/requires.txt +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/imsciences.egg-info/top_level.txt +0 -0
- {imsciences-0.6.0.7 → imsciences-0.6.0.8}/setup.cfg +0 -0
|
@@ -9,7 +9,7 @@ import re
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from fredapi import Fred
|
|
11
11
|
import time
|
|
12
|
-
from datetime import datetime
|
|
12
|
+
from datetime import datetime,timedelta
|
|
13
13
|
from cif import cif
|
|
14
14
|
from io import StringIO
|
|
15
15
|
import urllib
|
|
@@ -440,7 +440,7 @@ class dataprocessing:
|
|
|
440
440
|
|
|
441
441
|
return fig
|
|
442
442
|
|
|
443
|
-
def week_of_year_mapping(
|
|
443
|
+
def week_of_year_mapping(df, week_col, start_day_str):
|
|
444
444
|
|
|
445
445
|
# Mapping of string day names to day numbers (1 for Monday, 7 for Sunday)
|
|
446
446
|
day_mapping = {
|
|
@@ -456,15 +456,15 @@ class dataprocessing:
|
|
|
456
456
|
def week_to_startdate(week_str, start_day):
|
|
457
457
|
year, week = map(int, week_str.split('-W'))
|
|
458
458
|
first_day_of_year = datetime(year, 1, 1)
|
|
459
|
-
|
|
460
|
-
days_to_add = (7 - day_of_week + 1) if day_of_week > 4 else (1 - day_of_week)
|
|
461
|
-
start_of_iso_week = first_day_of_year + datetime.timedelta(days=days_to_add)
|
|
459
|
+
first_weekday_of_year = first_day_of_year.weekday() # Monday is 0 and Sunday is 6
|
|
462
460
|
|
|
463
|
-
#
|
|
464
|
-
|
|
465
|
-
|
|
461
|
+
# Calculate days to adjust to the desired start day of the week
|
|
462
|
+
days_to_adjust = (start_day - 1 - first_weekday_of_year) % 7
|
|
463
|
+
start_of_iso_week = first_day_of_year + timedelta(days=days_to_adjust)
|
|
466
464
|
|
|
467
|
-
|
|
465
|
+
# Calculate the start of the desired week
|
|
466
|
+
start_of_week = start_of_iso_week + timedelta(weeks=week - 1)
|
|
467
|
+
return start_of_week
|
|
468
468
|
|
|
469
469
|
# Apply the function to each row in the specified week column
|
|
470
470
|
df['OBS'] = df[week_col].apply(lambda x: week_to_startdate(x, start_day)).dt.strftime('%d/%m/%Y')
|
|
@@ -1334,7 +1334,7 @@ class datapull:
|
|
|
1334
1334
|
print(" - Usage: pull_ons_data(series_list, week_commencing)")
|
|
1335
1335
|
print(" - Example: pull_ons_data([{'series_id': 'LMSBSA', 'dataset_id': 'LMS'}], 'mon')")
|
|
1336
1336
|
|
|
1337
|
-
print("\n4.
|
|
1337
|
+
print("\n4. pull_oecd")
|
|
1338
1338
|
print(" - Description: Fetch macroeconomic data from OECD and other sources for a specified country.")
|
|
1339
1339
|
print(" - Usage: pull_macro(country='GBR', week_commencing='mon')")
|
|
1340
1340
|
print(" - Example: pull_macro('GBR', 'mon')")
|
|
@@ -2708,5 +2708,4 @@ class datapull:
|
|
|
2708
2708
|
|
|
2709
2709
|
final_weather = ims_proc.rename_cols(merged_df, 'seas_')
|
|
2710
2710
|
|
|
2711
|
-
return final_weather
|
|
2712
|
-
|
|
2711
|
+
return final_weather
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|