【Pandas】常用api(加精)

list转dataframe

用于制作label

python 复制代码
label_list = []
for label in df_label_data.values:
    if label == 0:
        label_list.append([0, 0]) # 
    elif label == 1:
        label_list.append([1, 0]) # 曝光点击了ctr,未点击购买
    elif label == 2:
        label_list.append([1, 1]) # 曝光点击了,且点击购买了


print(df_label_data.values)
[0 0 0 ... 0 0 0]
python 复制代码
df_label = pd.DataFrame(np.array(label_list), columns=['click', 'conversion'])
print(df_label.shape)

(17717195, 2)
相关推荐
飞梦工作室5 天前
突破 pandas 瓶颈:实时读写 Excel 与超透视汇总函数的双维解决方案
python·excel·pandas
Python大数据分析@6 天前
Vaex :突破pandas,快速分析100G大数据量
pandas
AI小云6 天前
【数据操作与可视化】Pandas数据处理-Series数据结构
开发语言·数据结构·python·numpy·pandas
小兔崽子去哪了8 天前
Numpy、Panads
python·numpy·pandas
一晌小贪欢8 天前
Pandas操作Excel使用手册大全:从基础到精通
开发语言·python·自动化·excel·pandas·办公自动化·python办公
CodeLongBear10 天前
Python数据分析 -- Pandas基础入门学习笔记:从核心概念到实操代码
python·conda·pandas
njxiejing11 天前
Python pandas基础:Series数据操作详解
数据结构·pandas
F_D_Z15 天前
DataFrame中.iloc 属性
pandas·dataframe·.iloc
husterlichf16 天前
pandas__unstack方法与set_index详解
数据挖掘·数据分析·pandas