登录用户行为量化(用户id提取)

# -*- coding: utf-8 -*-
"""
Created on Thu Mar  7 10:40:18 2019

@author: zhanggl21
"""

#登录用户行为数据
#1.将数据读入内存
import pandas as pd

#df1=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2018年11月-登录用户行为报表.xlsx')
#df2=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2018年12月-登录用户行为报表.xlsx')
#df3=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(1.1-1.13)登录用户行为报表.xlsx')
#df4=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(1.14-1.27)登录用户行为报表.xlsx')
#df5=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(1.28-2.17)登录用户行为报表.xlsx')
#df6=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(2.18-2.24)登录用户行为报表.xlsx')
#df7=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(2.25-3.3)登录用户行为报表.xlsx')
#df8=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(3.4-3.10)登录用户行为报表.xlsx')
#df9=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(3.11-3.17)登录用户行为报表.xlsx')
#df10=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(3.18-3.24)登录用户行为报表.xlsx')
#df11=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(3.25-3.31)登录用户行为报表.xlsx')

df12=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(4.1-4.7)登录用户行为报表.xlsx')
df13=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(4.8-4.14)登录用户行为报表.xlsx')
df14=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(4.15-4.21)登录用户行为报表.xlsx')
df15=pd.read_excel(r'E:\暂存\登录用户量化表20190114\2019年(4.22-4.30)登录用户行为报表.xlsx')


#将表联结到一起
hebing=[df12,df13,df14,df15]
denglu=pd.concat(hebing,join='outer',ignore_index=True)


'''
长
闵
徐
静
'''
dfqy=denglu[(denglu.区域=='长宁区')|(denglu.区域=='闵行区')|(denglu.区域=='徐汇区')|(denglu.区域=='静安区')]
print('2019年4月浏览徐汇、闵行、长宁、静安区域房源的用户\n有',len(dfqy.用户ID.unique()),'个')


dfqy.用户ID.drop_duplicates().to_excel(r'd:\Users\zhanggl21\Desktop\近1月浏览四个区域的用户.xlsx')


phone_num=pd.read_excel(r'E:\备份-暂存\2019年4月浏览四个区域的用户\phone.xlsx')

april_call=pd.read_excel(r'd:\Users\zhanggl21\Desktop\6666\上月直聊委托约看400\4月400来电.xlsx')

phone_num.info()
april_call.info()

not_call_yet=phone_num[~phone_num.PHONE.isin(april_call.客户信息.unique())]

print('2019年4月浏览徐汇、闵行、长宁、静安区域房源的用户\n还未拨打电话的有',\
      len(not_call_yet.PHONE.unique()),'个')


#导出
dfqy.用户ID=dfqy.用户ID.str.rstrip()
dfqy[dfqy.用户ID.isin(not_call_yet.USERID.unique())].to_excel(r'd:\Users\zhanggl21\Desktop\2019年4月浏览徐汇、闵行、长宁、静安区域房源但还未拨打电话的用户.xlsx')





'''
#提取浏览总价为350万以下的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.价格<=3500000),['用户ID','户型']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''




'''
#提取浏览户型为2室的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.户型.str.contains('2室')),['用户ID','户型']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''



'''
#提取浏览区域为虹口区的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.区域=='虹口区'),['用户ID','户型']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''

'''
#提取浏览价格为150万-500万的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.价格>=1500000)\
                 &(denglu.价格<=5000000),['用户ID','户型']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''





'''
#提取浏览区域为杨浦区的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.户型.str.contains('2室')),['用户ID','户型']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''



'''
#提取浏览区域为杨浦区的二手房源的用户id
import numpy as np
yangpu=denglu.loc[(denglu.租售类型=='二手房')&(denglu.区域=='杨浦区'),['用户ID','区域','价格']]

userid=yangpu.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''




'''
#提取浏览价格为200-350万的二手房源的用户id
import numpy as np
ershi=denglu.loc[(denglu.租售类型=='二手房')&(denglu.价格>=2000000)&(denglu.价格<=3500000),['用户ID','价格']]

userid=ershi.drop_duplicates()
#导出到excel
userid.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''



'''
#提取浏览户型为2室的二手房源的用户id
import numpy as np
ershi=denglu['用户ID'][np.logical_and(denglu['户型'].str.contains('2室'),denglu['租售类型']=='二手房')]
es=ershi.drop_duplicates()
#导出到excel
es.to_excel(r'd:\Users\zhanggl21\Desktop\es.xlsx')
'''


'''
#提取宝山区的二手房房源的用户id
bs_id=denglu['用户ID']\
[(denglu['租售类型']=='二手房')&(denglu['区域']=='宝山区')]\
.drop_duplicates()

bs_id.to_excel(r'd:\Users\zhanggl21\Desktop\bs_id.xlsx')
'''


'''
#提取浏览价格段为500万-800万的二手房房源的用户id
import numpy as np
fe_id=denglu['用户ID']\
[(denglu['租售类型']=='二手房')&(denglu['价格']>=5000000)&(denglu['价格']<=8000000)]\
.drop_duplicates()

fe_id.to_excel(r'd:\Users\zhanggl21\Desktop\fe_id.xlsx')
'''

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值