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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.6.0.7
3
+ Version: 0.6.0.8
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -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(self, df, week_col, start_day_str):
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
- day_of_week = first_day_of_year.isocalendar()[2]
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
- # Adjust start day
464
- days_to_shift = (start_day - 1) % 7
465
- start_of_week = start_of_iso_week + datetime.timedelta(days=days_to_shift)
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
- return start_of_week + datetime.timedelta(weeks=week - 1)
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. pull_macro")
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.6.0.7
3
+ Version: 0.6.0.8
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -8,7 +8,7 @@ def read_md(file_name):
8
8
  return f.read()
9
9
  return ''
10
10
 
11
- VERSION = '0.6.0.7'
11
+ VERSION = '0.6.0.8'
12
12
  DESCRIPTION = 'IMS Data Processing Package'
13
13
  LONG_DESCRIPTION = read_md('README.md') # Reading from README.md
14
14
 
File without changes
File without changes