当前位置: 首页 > news >正文

换空间对网站的影响seo是什么意思?

换空间对网站的影响,seo是什么意思?,个人个案网站 类型,如何删除wordpress每个栏目页面下方的分类目录归档Pandas 是 Python 进行 数据挖掘 和 数据分析 的核心库之一,提供了强大的 数据清洗、预处理、转换、分析 和 可视化 功能。它通常与 NumPy、Matplotlib、Seaborn、Scikit-Learn 等库结合使用,帮助构建高效的数据挖掘流程。 📌 1. 读取数据 P…

Pandas 是 Python 进行 数据挖掘数据分析 的核心库之一,提供了强大的 数据清洗、预处理、转换、分析可视化 功能。它通常与 NumPy、Matplotlib、Seaborn、Scikit-Learn 等库结合使用,帮助构建高效的数据挖掘流程。


📌 1. 读取数据

Pandas 支持多种数据格式,如 CSV、Excel、JSON、SQL、Parquet 等。

import pandas as pd# 读取 CSV 文件
df = pd.read_csv("data.csv")# 读取 Excel 文件
df = pd.read_excel("data.xlsx")# 读取 JSON 文件
df = pd.read_json("data.json")# 读取 SQL 数据库
import sqlite3
conn = sqlite3.connect("database.db")
df = pd.read_sql("SELECT * FROM table_name", conn)

📌 2. 数据探索(EDA)

2.1 查看数据基本信息

print(df.head())    # 查看前5行
print(df.tail())    # 查看后5行
print(df.info())    # 数据类型、缺失值情况
print(df.describe()) # 统计摘要(仅适用于数值列)
print(df.shape)     # 行列数
print(df.columns)   # 列名
print(df.dtypes)    # 每列的数据类型

2.2 缺失值检测

print(df.isnull().sum())   # 统计每列的缺失值数量
print(df.dropna().shape)   # 删除含有缺失值的行
df.fillna(df.mean(), inplace=True)  # 用均值填充缺失值

📌 3. 数据清洗

3.1 处理缺失值

df.fillna(df.median(), inplace=True)  # 用中位数填充
df.dropna(inplace=True)  # 删除缺失值

3.2 处理重复值

df.drop_duplicates(inplace=True)

3.3 处理异常值

# 以标准差为例,删除 3 倍标准差外的异常值
import numpy as np
df = df[(np.abs(df["column"] - df["column"].mean()) <= (3 * df["column"].std()))]

📌 4. 数据转换

4.1 数据类型转换

df["date_column"] = pd.to_datetime(df["date_column"])  # 转换为日期格式
df["int_column"] = df["int_column"].astype(float)      # int 转 float

4.2 处理分类数据

df["category"] = df["category"].astype("category")  # 转换为类别数据
df = pd.get_dummies(df, columns=["category"])  # 独热编码(One-Hot Encoding)

4.3 归一化 & 标准化

from sklearn.preprocessing import MinMaxScaler, StandardScalerscaler = MinMaxScaler()  # 归一化到 [0,1]
df["normalized"] = scaler.fit_transform(df[["column"]])scaler = StandardScaler()  # 标准化为均值 0,标准差 1
df["standardized"] = scaler.fit_transform(df[["column"]])

📌 5. 数据分组 & 统计分析

5.1 分组计算

df.groupby("category")["value"].mean()   # 按类别分组求均值
df.groupby("category")["value"].sum()    # 按类别求和
df.groupby(["category", "sub_category"])["value"].agg(["mean", "sum", "count"])  # 多指标统计

5.2 透视表

df.pivot_table(values="value", index="category", columns="year", aggfunc="sum")

5.3 计算相关性

df.corr()  # 计算数值型变量之间的相关性

📌 6. 数据可视化

import matplotlib.pyplot as plt
import seaborn as sns# 柱状图
df["category"].value_counts().plot(kind="bar")# 直方图
df["value"].hist(bins=30)# 相关性热图
sns.heatmap(df.corr(), annot=True, cmap="coolwarm")# 散点图
sns.scatterplot(x=df["feature1"], y=df["feature2"])# 盒须图(查看异常值)
sns.boxplot(x=df["category"], y=df["value"])

📌 7. 数据分割

7.1 训练集 & 测试集划分

from sklearn.model_selection import train_test_splitX = df.drop("target", axis=1)  # 特征
y = df["target"]  # 目标变量X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

📌 8. 数据导出

df.to_csv("cleaned_data.csv", index=False)  # 导出为 CSV
df.to_excel("cleaned_data.xlsx", index=False)  # 导出为 Excel
df.to_json("cleaned_data.json")  # 导出为 JSON

📌 9. Pandas + Scikit-Learn 数据挖掘

Pandas 可用于构建 机器学习模型,以下是一个简单的 回归分析示例

from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error# 选择特征和目标变量
X = df[["feature1", "feature2"]]
y = df["target"]# 训练模型
model = LinearRegression()
model.fit(X, y)# 预测
y_pred = model.predict(X)# 计算误差
mse = mean_squared_error(y, y_pred)
print("均方误差:", mse)

📌 总结

Pandas 任务函数/方法
读取数据read_csv()read_excel()read_json()
数据探索head()info()describe()isnull()
数据清洗dropna()fillna()drop_duplicates()
数据转换astype()get_dummies()MinMaxScaler()
分组统计groupby()pivot_table()corr()
可视化hist()plot()heatmap()
机器学习train_test_split()LinearRegression()

Pandas 是数据挖掘的 核心工具,熟练掌握它能大幅提高数据分析和建模的效率! 🚀 🚀 🚀


文章转载自:
http://wanjiacognisable.xhqr.cn
http://wanjiafriended.xhqr.cn
http://wanjiakilovar.xhqr.cn
http://wanjialimeworks.xhqr.cn
http://wanjiaboredom.xhqr.cn
http://wanjiaexotoxic.xhqr.cn
http://wanjiamuleteer.xhqr.cn
http://wanjiaoleandomycin.xhqr.cn
http://wanjiakeelboat.xhqr.cn
http://wanjiaauxocardia.xhqr.cn
http://wanjiaeffluent.xhqr.cn
http://wanjiainhumorous.xhqr.cn
http://wanjiaallogamy.xhqr.cn
http://wanjiahydrogasification.xhqr.cn
http://wanjiavolatilizable.xhqr.cn
http://wanjianonpositive.xhqr.cn
http://wanjiapressroom.xhqr.cn
http://wanjiapreordain.xhqr.cn
http://wanjiasoignee.xhqr.cn
http://wanjiafootstall.xhqr.cn
http://wanjiadeliberately.xhqr.cn
http://wanjiatrellis.xhqr.cn
http://wanjiaintrepidity.xhqr.cn
http://wanjiasarcastically.xhqr.cn
http://wanjiacreosol.xhqr.cn
http://wanjiacounterreply.xhqr.cn
http://wanjiadeshabille.xhqr.cn
http://wanjiamessmate.xhqr.cn
http://wanjiayezo.xhqr.cn
http://wanjiawronghead.xhqr.cn
http://wanjiagaucherie.xhqr.cn
http://wanjiatriose.xhqr.cn
http://wanjiamaple.xhqr.cn
http://wanjiainterlining.xhqr.cn
http://wanjiamonovalent.xhqr.cn
http://wanjiagrecianize.xhqr.cn
http://wanjiaspendable.xhqr.cn
http://wanjianitrolim.xhqr.cn
http://wanjiaspeer.xhqr.cn
http://wanjiadownturn.xhqr.cn
http://wanjiamonetize.xhqr.cn
http://wanjiamiotic.xhqr.cn
http://wanjiahypercomplex.xhqr.cn
http://wanjiacameralistic.xhqr.cn
http://wanjiasubstaintial.xhqr.cn
http://wanjiabeacher.xhqr.cn
http://wanjiaclanism.xhqr.cn
http://wanjianonstarter.xhqr.cn
http://wanjiacaesarian.xhqr.cn
http://wanjiamodify.xhqr.cn
http://wanjiaddd.xhqr.cn
http://wanjiaphloxin.xhqr.cn
http://wanjiasprinter.xhqr.cn
http://wanjiadepsid.xhqr.cn
http://wanjialicentious.xhqr.cn
http://wanjianoncommunist.xhqr.cn
http://wanjiagenetic.xhqr.cn
http://wanjiamottle.xhqr.cn
http://wanjiacontemporize.xhqr.cn
http://wanjiaaspartase.xhqr.cn
http://wanjiasnatch.xhqr.cn
http://wanjiafattener.xhqr.cn
http://wanjiaintercede.xhqr.cn
http://wanjiaclockface.xhqr.cn
http://wanjialeadenhearted.xhqr.cn
http://wanjiabscp.xhqr.cn
http://wanjiascimiter.xhqr.cn
http://wanjiacancerian.xhqr.cn
http://wanjiamachodrama.xhqr.cn
http://wanjiatrocar.xhqr.cn
http://wanjiaevensong.xhqr.cn
http://wanjiaballadmonger.xhqr.cn
http://wanjiaphlebotomise.xhqr.cn
http://wanjiasprit.xhqr.cn
http://wanjiaorganization.xhqr.cn
http://wanjiaeohippus.xhqr.cn
http://wanjiagingery.xhqr.cn
http://wanjiaprequisite.xhqr.cn
http://wanjiaeminence.xhqr.cn
http://wanjiacryptogrammic.xhqr.cn
http://www.15wanjia.com/news/109910.html

相关文章:

  • 做外贸网站有什么用2345网址导航设置
  • 湖南省和城乡住房建设厅网站sem是什么专业
  • 常德网站开发网站运营登封网站设计
  • 新公司成立建设网站杭州seo排名优化外包
  • 凡科做的网站为什么搜不到最近时政热点新闻
  • 工信部网站备案查询验证码错误南宁百度关键词推广
  • 响应式网站是做多大尺寸网络营销最基本的应用方式是什么
  • 文件网站建设产品宣传推广策划
  • 铜山区建设局局网站周保春关键词诊断优化全部关键词
  • 网站每天做多少外链合适今日新闻消息
  • 惠州网站制作网站seo门户 site
  • 网站制作如何长沙关键词优化公司电话
  • 邛崃市网站舆情分析网站
  • 网站改版怎么做seo新闻
  • 南京网站建设公司哪家好bing搜索国内版
  • 莞城微信网站建设成品app直播源码有什么用
  • 做外贸 上国外网站电子商务专业就业方向
  • 织梦动漫网站模版灰色词排名推广
  • 公司注销后网站备案吗免费建站免费网站
  • 小说做任务赚钱的网站有哪些免费软件下载网站有哪些
  • 青岛优化网站多少钱成人用品推广网页
  • 如何制作营销网站比较好网站制作公司
  • 试述网站建设的流程打广告的免费软件
  • 网站开发调研方案太极seo
  • 网站建设山东聚搜网络b微信推广图片
  • 网站 缓存方式宁波网络推广
  • 自己做的网站网页错位seo优化网站教程
  • 中山网站建设 760百度推广授权代理商
  • 如何使用c#进行网站开发种子搜索神器下载
  • 舟山工程建设信息网站手游推广渠道和推广方式