adding latest working version *
This commit is contained in:
@@ -419,17 +419,14 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
_count = [d for d in _count if d > 1]
|
_count = [d for d in _count if d > 1]
|
||||||
_d = self.get_descriptive_statistics(_count)
|
_d = self.get_descriptive_statistics(_count)
|
||||||
self.album_statistics = addict.Dict(
|
self.album_statistics = addict.Dict(
|
||||||
**self.album_statistics,
|
**self.album_statistics, **addict.Dict((album, _d))
|
||||||
**addict.Dict(
|
|
||||||
(album, _d)
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
pprint(self.album_statistics)
|
pprint(self.album_statistics)
|
||||||
|
|
||||||
# implement above in this
|
# implement above in this
|
||||||
def calculate_final_average_by_year(self) -> None:
|
def calculate_final_average_by_year(self) -> None:
|
||||||
group_by_years = addict.Dict()
|
group_by_years = addict.Dict()
|
||||||
self.year_averages = addict.Dict()
|
self.year_statistics = addict.Dict()
|
||||||
# album_lyrics = self.all_albums_lyrics_sum
|
# album_lyrics = self.all_albums_lyrics_sum
|
||||||
with open(f'{os.getcwd()}/lyrics_sum_all_album.json', 'r') as f:
|
with open(f'{os.getcwd()}/lyrics_sum_all_album.json', 'r') as f:
|
||||||
album_lyrics = json.load(f)
|
album_lyrics = json.load(f)
|
||||||
@@ -447,19 +444,25 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
except TypeError:
|
except TypeError:
|
||||||
group_by_years.get(year).extend(count)
|
group_by_years.get(year).extend(count)
|
||||||
for year, y_count in group_by_years.items():
|
for year, y_count in group_by_years.items():
|
||||||
year_total, year_running = (0, 0)
|
# year_total, year_running = (0, 0)
|
||||||
for y in y_count:
|
# for y in y_count:
|
||||||
if isinstance(y, int):
|
# if isinstance(y, int):
|
||||||
year_running += y
|
# year_running += y
|
||||||
year_total += 1
|
# year_total += 1
|
||||||
else:
|
# else:
|
||||||
pass
|
# pass
|
||||||
avg = math.ceil(year_running / year_total)
|
_y_count = [d for d in y_count if isinstance(d, int)]
|
||||||
# print(year, avg)
|
_y_count = [d for d in _y_count if d > 1]
|
||||||
self.year_averages = addict.Dict(
|
_d = self.get_descriptive_statistics(_y_count)
|
||||||
**self.year_averages, **addict.Dict((year, avg))
|
self.year_statistics = addict.Dict(
|
||||||
|
**self.year_statistics, **addict.Dict((year, _d))
|
||||||
)
|
)
|
||||||
print(self.year_averages)
|
# avg = math.ceil(year_running / year_total)
|
||||||
|
# print(year, avg)
|
||||||
|
# self.year_statistics = addict.Dict(
|
||||||
|
# **self.year_statistics, **addict.Dict((year, avg))
|
||||||
|
# )
|
||||||
|
pprint(self.year_statistics)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def construct_lyrics_url(artist: str, song: str) -> str:
|
def construct_lyrics_url(artist: str, song: str) -> str:
|
||||||
@@ -494,6 +497,7 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
p_25 = math.ceil(numpy.percentile(nums, 25))
|
p_25 = math.ceil(numpy.percentile(nums, 25))
|
||||||
p_75 = math.ceil(numpy.percentile(nums, 75))
|
p_75 = math.ceil(numpy.percentile(nums, 75))
|
||||||
p_90 = math.ceil(numpy.percentile(nums, 90))
|
p_90 = math.ceil(numpy.percentile(nums, 90))
|
||||||
|
count = len(nums)
|
||||||
_d = addict.Dict(
|
_d = addict.Dict(
|
||||||
('avg', avg),
|
('avg', avg),
|
||||||
('median', median),
|
('median', median),
|
||||||
@@ -504,6 +508,7 @@ class LyricsBuilder(LyricsConcreteBuilder):
|
|||||||
('p_25', p_25),
|
('p_25', p_25),
|
||||||
('p_75', p_75),
|
('p_75', p_75),
|
||||||
('p_90', p_90),
|
('p_90', p_90),
|
||||||
|
('count', count)
|
||||||
)
|
)
|
||||||
return _d
|
return _d
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user