【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)
相关推荐
laocooon52385788611 小时前
对传入的 x , y 两个数组做折线图, x 对应 x 轴, y 对应 y 轴。并保存到 Task1/image1/T2.png
python·numpy·pandas·matplotlib
Maxwell_li11 天前
新冠检测例子学习查准率和召回率
学习·机器学习·数据分析·回归·numpy·pandas
渡我白衣1 天前
Python 与数据科学工具链入门:NumPy、Pandas、Matplotlib 快速上手
人工智能·python·机器学习·自然语言处理·numpy·pandas·matplotlib
IT北辰2 天前
用 Python 自动解析药品规格并计算包装总容量 —— pandas + 正则实战
开发语言·python·pandas
lbb 小魔仙2 天前
Python 读取 Excel 文件:openpyxl 与 pandas 实战对比
python·excel·pandas
Amber_372 天前
数据分析之(MySQL+普通程序) VS (Python的NumPy/Pandas)
python·mysql·数据分析·numpy·pandas
Lucky高3 天前
Pandas库实践3_索引
开发语言·python·pandas
墨上烟雨3 天前
Pandas读写CSV、Excel、JSON文件
pandas
Serendipity_Carl5 天前
京东手机销售数据分析: 从数据清洗到可视化仪表盘
python·数据分析·pandas·pyecharts
一位代码5 天前
pandas | 查看数据特征的常见属性及方法
pandas