pandas库的基本使用
pandas库的基本使用
发现自己从来都是丢给GPT而没写过类似的pandas,想开始试试kaggle的时候看到有相关教程,就记记笔记
import pandas as pd
file_path = 'xxx.csv'
data = pd.read_csv(file_path) # 读取csv文件
data.describe()#打印全表
上面就是最基础的操作,如果想展示列的话
data.columns
如果想丢弃有缺失值的值的话
new_data = data.dropna(axis=0)#丢弃行
new_data = data.dropna(axis=1)#丢弃列
Dot notation, which we use to select the “prediction target” 我把这个理解为一种点标注,标注一个属性用来预测
y = melbourne_data.Price#选择melbourne_data的Price列作为预测目标
选择筛选对应的属性特征
melbourne_features = ['Rooms', 'Bathroom', 'Landsize', 'Lattitude', 'Longtitude']
X = melbourne_data[melbourne_features]
X.describe()
Enjoy Reading This Article?
Here are some more articles you might like to read next:
- Google Gemini updates: Flash 1.5, Gemma 2 and Project Astra
- Displaying External Posts on Your al-folio Blog
- Graph RAG with Milvus —— 纯向量库造图的多跳推理
- Hierarchical Indices 层级索引 —— 先粗后细的两级检索
- HyDE 与 HyPE —— 假设检索技术的两个方向
- 二叉树刷题总结
- RAG 技术体系化分类——从 Pipeline 阶段到失败模式
- MemoRAG 记忆增强型 RAG 总结
- Microsoft GraphRAG 基于知识图谱的 RAG 总结
- Multimodal RAG with Captioning 图像描述型多模态 RAG 总结