Glider
Loading...
Searching...
No Matches
State51Template.py
Go to the documentation of this file.
1import re
2
4 def serviceFinder(self, service):
5 # print(service)
6 if "Red" in service:
7 return "YouTube Music"
8 elif "UMA" in service:
9 return "UMA"
10 elif "Deezer" in service:
11 return "Deezer"
12 elif "Google Play" in service:
13 return "Google Play"
14 elif "- YouTube" in service or "Youtube Ads Revenue" in service:
15 return "YouTube Content ID"
16 elif "YouTube - Subscription" in service:
17 return "YouTube Music"
18 elif "iTunes" in service:
19 return "iTunes"
20 elif "Amazon" in service:
21 return "Amazon"
22 elif "Spotify" in service:
23 return "Spotify"
24 elif "Tencent" in service:
25 return "Tencent"
26 elif "Tidal" in service:
27 return "Tidal"
28 elif "Alibaba" in service:
29 return "Alibaba"
30 elif "Netease" in service:
31 return "Netease"
32 elif "Pandora" in service:
33 return "Pandora"
34 elif "Yandex" in service:
35 return "Yandex"
36 elif "Facebook" in service:
37 return "Facebook"
38 elif "Audio tier" in service:
39 return "Youtube Audio Tier"
40 elif "Tik Tok" in service:
41 return "TikTok"
42 elif "Slacker" in service:
43 return "Slacker"
44 elif "Soundcloud" in service:
45 return "Soundcloud"
46 return service
47
48 def type(self, service):
49 """Maps the sale type using the service, according to their requirements
50 Args:
51 service (str): service shown in the original file
52 Returns: (sale type in a single one letter)
53 """
54 if "Amazon" in service or "Google Play" in service:
55 return "T"
56 return "S"
57
58 def assetType(self, df):
59 """Applies type functions to current dataframe
60 Args:
61 df (pandas dataframe): dataframe where changes will applied
62 Returns: df (pandas dataframe)
63 """
64 df['getservice'] = df.apply(lambda Row: self.serviceFinder(Row['music service']), axis=1)
65 df["gettypestate51"] = df.apply(lambda Row: self.type(Row['getservice']), axis=1)
66 print("type")
67 return df
68
69 def date(self, filename):
70 """Sets date column given the filename (it contains the date)
71 For example 12822_detail_2021_12_14_982.csv
72 Args:
73 filename (str): current filename
74 Returns: date_str (str)
75 """
76 # "12822_detail_2021_12_14_982.csv"
77 year = re.findall(r'_\d{4}_', filename)[0]
78 month = re.findall(r'_\d{2}_', filename)[0]
79 year = year.replace("_", "")
80 month = month.replace("_", "")
81 date_str = year+month
82 return date_str