-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_3_3_2.py
31 lines (24 loc) · 1.27 KB
/
task_3_3_2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import pandas as pd
import numpy as np
def create_vacancies(file_name):
print('Запуск формирования файла по вакансиям')
pd.set_option('expand_frame_repr', False)
currency_data = pd.read_csv('currencies.csv')
currency_data = currency_data.set_index('date')
print('Подгрузка файла по валютам')
print(currency_data.head())
currency = list(currency_data.columns)
df = pd.read_csv(file_name)
print('Открытие файла по вакансиям')
df.salary_from = df[['salary_from', 'salary_to']].mean(axis=1)
df['date'] = df.published_at.apply(lambda z: z[:7])
df['salary_from'] = df.apply(
lambda x: float(x['salary_from'] * currency_data.at[x['date'], x['salary_currency']])
if (x['salary_currency'] != 'RUR' and not np.isnan(x['salary_from']))
else x['salary_from'], axis=1)
df = df.drop(['salary_to', 'date', 'salary_currency'], axis=1).rename(columns={'salary_from': 'salary'})
# df.head(100).to_csv('first100vacancies.csv', index=False)
df.to_csv('vacancies_new.csv', index=False)
print('Создание итогового файла по вакансиям')
if __name__ == '__main__':
create_vacancies('vacancies_dif_currencies.csv')