数据:mr数据,每个采样点有主服务小区以及7个邻区的eci、rsrp、mr_count信息;
需求:需要将邻区独立生成一个采样点,处理后采样点基本就是原数据的7倍
大概就是这样子:
使用stack/unstack可以很方便地进行行列转换,但想要的实现的要比行列转化更复杂些。不过使用pandas来处理也比较简单
1、读取数据:
t = pd.read_csv('./fastPg.csv',delimiter= ",",encoding='gbk')
t.columns=[x.lower() for x in t.columns]
output:
2、提取小区数据,t1~t7代表7个最强邻区:
scell=t[['longitude','latitude','eci','mr_count','avg_rsrp']]
for i in range(1,8):
exec("t{0}=t[['longitude','latitude','t{0}_ecgi','t{0}_count','t{0}_rsrp']]".format(i))
t1,output:
3、把字段名统一并使用concat函数连接
for df in [scell,t1,t2]:
df.columns=['longitude','latitude','eci','mr_count','avg_rsrp']
df=pd.concat([scell,t1,t2])
df
df, output: