【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)
相关推荐
人工干智能1 天前
Pandas核心数据结构:Series与DataFrame
数据结构·python·pandas
智航GIS2 天前
11.7 使用Pandas 模块中describe()、groupby()进行简单分析
python·pandas
人工干智能2 天前
python的高级技巧:Pandas中的`iloc[]`和`loc[]`
开发语言·python·pandas
智航GIS3 天前
11.6 Pandas数据处理进阶:缺失值处理与数据类型转换完全指南
python·pandas
西红市杰出青年3 天前
crawl4ai------AsyncPlaywrightCrawlerStrategy使用教程
开发语言·python·架构·正则表达式·pandas
CCPC不拿奖不改名4 天前
数据处理与分析:pandas基础+面试习题
开发语言·数据结构·python·面试·职场和发展·pandas
4***17544 天前
Python酷库之旅-第三方库Pandas(051)
开发语言·python·pandas
万粉变现经纪人5 天前
如何解决 pip install mysqlclient 报错 ‘mysql_config’ not found 问题
数据库·python·mysql·pycharm·bug·pandas·pip
智航GIS5 天前
11.3 Pandas 模块功能概览
python·信息可视化·pandas
White-Camellia5 天前
Pandas多个数据表合并(merge)
pandas