Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pd = __import__('pandas')
- np = __import__('numpy')
- df = pd.read_csv('https://vk.com/s/v1/doc/Q8dE2aqabEx6LLW_FVGZLwrYk0afhuc1JKCC5PfvrlxBgaKyrGI', names=['date', 'name', 'price'])
- # df.head()
- # date name price
- # 0 01.01.2020 сайт1 123000
- # 1 01.02.2020 сайт1 154000
- # 2 01.03.2020 сайт1 164000
- # 3 01.04.2020 сайт1 124000
- # 4 01.05.2020 сайт1 178000
- def func(data):
- res = np.nan
- if data < 154000:
- res = 'min'
- if data > 154000 and data < 165000:
- res = 'medium'
- else:
- res = 'high'
- return res
- df['res'] = df['price'].apply(func)
- df.head()
- # date name price res
- # 0 01.01.2020 сайт1 123000 high
- # 1 01.02.2020 сайт1 154000 high
- # 2 01.03.2020 сайт1 164000 medium
- # 3 01.04.2020 сайт1 124000 high
- # 4 01.05.2020 сайт1 178000 high
Advertisement
Add Comment
Please, Sign In to add comment