imsciences 0.9.5.8__tar.gz → 0.9.5.9__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.9.5.8
3
+ Version: 0.9.5.9
4
4
  Summary: IMS Data Processing Package
5
5
  Author: IMS
6
6
  Author-email: cam@im-sciences.com
@@ -1554,4 +1554,27 @@ class dataprocessing:
1554
1554
  "combined_features": combined_features,
1555
1555
  }
1556
1556
 
1557
- return output
1557
+ return output
1558
+
1559
+ def quid_pr (self, df):
1560
+ def convert_date(date_str):
1561
+ try:
1562
+ return datetime.strptime(date_str, '%b %d, %Y')
1563
+ except ValueError:
1564
+ return None # Return None if conversion fails
1565
+ # Apply conversion to create new columns
1566
+ df['Start Date'] = df['Earliest Published'].astype(str).apply(convert_date)
1567
+ df['End Date'] = df['Latest Published'].astype(str).apply(convert_date)
1568
+ df['Days Duration'] = (df['End Date'] - df['Start Date']).dt.days + 1 # Ensure inclusive range
1569
+ df['Count per Day'] = df['Published Count'] / df['Days Duration'] # Calculate count per day
1570
+ df['Social Engagement per Day'] = df['Social Engagement'] / df['Days Duration']
1571
+ df['Week Start'] = df['Start Date'].apply(lambda x: x - timedelta(days=x.weekday()) if pd.notnull(x) else None)
1572
+ count_df = df.groupby('Week Start')['Count per Day'].sum().reset_index()
1573
+ total_engagement_per_company = df.groupby('Company (Primary Mention)')['Social Engagement'].sum().reset_index() # Caluclates Social Engagement across whole period
1574
+ valid_companies = total_engagement_per_company[total_engagement_per_company['Social Engagement'] > 0]['Company (Primary Mention)'] # Filters out Companies with no Social Engagement
1575
+ social_engagement_df = df[df['Company (Primary Mention)'].isin(valid_companies)].groupby(['Week Start', 'Company (Primary Mention)'])[
1576
+ 'Social Engagement'
1577
+ ].sum().reset_index()
1578
+ total_social_engagement_df = df.groupby('Week Start')['Social Engagement per Day'].sum().reset_index()
1579
+
1580
+ return count_df, total_social_engagement_df, social_engagement_df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imsciences
3
- Version: 0.9.5.8
3
+ Version: 0.9.5.9
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.9.5.8'
11
+ VERSION = '0.9.5.9'
12
12
  DESCRIPTION = 'IMS Data Processing Package'
13
13
  LONG_DESCRIPTION = read_md('README.md')
14
14
 
File without changes
File without changes
File without changes