Commit
•
0cb5606
1
Parent(s):
77aa593
Update news_category_prediction.py
Browse files
news_category_prediction.py
CHANGED
@@ -64,7 +64,7 @@ def predict_news_category(old_news: pd.DataFrame, new_news: pd.DataFrame, interp
|
|
64 |
if 'category' not in [*old_news.columns]:
|
65 |
logger.warning('No prior predictions found in old news')
|
66 |
if not cols_check([*new_news.columns], [*old_news.columns]):
|
67 |
-
raise
|
68 |
final_df = pd.concat([old_news, new_news], axis=0, ignore_index=True)
|
69 |
final_df.drop_duplicates(subset='url', keep='first', inplace=True)
|
70 |
headlines = [*final_df['title']].copy()
|
@@ -74,7 +74,7 @@ def predict_news_category(old_news: pd.DataFrame, new_news: pd.DataFrame, interp
|
|
74 |
else:
|
75 |
logger.warning('Prior predictions found in old news')
|
76 |
if not cols_check([*new_news.columns], [*old_news.columns][:-2]):
|
77 |
-
raise
|
78 |
old_urls = [*old_news['url']]
|
79 |
new_news = new_news.loc[new_news['url'].isin(old_urls) == False, :]
|
80 |
headlines = [*new_news['title']].copy()
|
|
|
64 |
if 'category' not in [*old_news.columns]:
|
65 |
logger.warning('No prior predictions found in old news')
|
66 |
if not cols_check([*new_news.columns], [*old_news.columns]):
|
67 |
+
raise Exception("New and old cols don't match")
|
68 |
final_df = pd.concat([old_news, new_news], axis=0, ignore_index=True)
|
69 |
final_df.drop_duplicates(subset='url', keep='first', inplace=True)
|
70 |
headlines = [*final_df['title']].copy()
|
|
|
74 |
else:
|
75 |
logger.warning('Prior predictions found in old news')
|
76 |
if not cols_check([*new_news.columns], [*old_news.columns][:-2]):
|
77 |
+
raise Exception("New and old cols don't match")
|
78 |
old_urls = [*old_news['url']]
|
79 |
new_news = new_news.loc[new_news['url'].isin(old_urls) == False, :]
|
80 |
headlines = [*new_news['title']].copy()
|