当前位置:网站首页>Dataframe first performs grouping operation and then combines output
Dataframe first performs grouping operation and then combines output
2022-07-25 20:02:00 【RS&Hydrology】
dataframe First group operation and then merge output : It mainly uses grouping functions groupby And merge function append、concat, Specific code :
For example, group first , Delete outliers for each group of data (MAD), Then merge the processed data into one dataframe Output .
import os
import pandas as pd
from pyod.models.mad import MAD
import warnings
warnings.filterwarnings('ignore')
#%%
#test
df = pd.read_csv('./21.csv')
# print(len(df))#2273824
def fit_model(model, data, column='s'):
# fit the model and predict it
df = data.copy()
data_to_predict = data[column].to_numpy().reshape(-1, 1)
predictions = model.fit_predict(data_to_predict)
df['Predictions_1'] = predictions
return df
df_groupby = df.groupby(["class"])#group by class
frames = []
for decyear,group in df_groupby:
# print(decyear)
# print(group)
mad_model = MAD()
group_mad = fit_model(mad_model,group)
group_mad_filter = group_mad[(group_mad['Predictions_1'] == 0)]
# print(group_mad_filter)
frames.append(group_mad_filter)
result = pd.concat(frames, axis=0, names=None)
print('done!')
边栏推荐
- Partial interpretation of yolov7 paper [including my own understanding]
- Univariate function integration_ Partial integral method
- Connecting to the database warning establishing SSL connection without server's identity verification is not recommended
- PyTorch 模型 onnx 文件的导出和调用
- 什么是唯心主义
- DIY个人服务器(diy存储服务器)
- How to set tiktok mobile network environment? How can tiktok break the playback volume?
- Bash does not add single quotes to your string
- 03-树1 树的同构
- Sentinel simple current limiting and degradation demo problem record
猜你喜欢

手机端触摸图片slider轮播插件photoswipe.js

Ml programming skills:
![[mindspore] [read graph data] cannot read mindrecord format graph data](/img/2a/6da73178993f3d0f84c1f6ada17884.png)
[mindspore] [read graph data] cannot read mindrecord format graph data

Rainbond插件扩展:基于Mysql-Exporter监控Mysql

滑雪手机端H5小游戏源码下载
![Summarize the level of intelligent manufacturing discussion [macro understanding]](/img/84/3addabdf857c562535a4085782d3e8.png)
Summarize the level of intelligent manufacturing discussion [macro understanding]

一元函数积分学_分部积分法

给容器添加3d效果的副标题

When AI encounters life and health, Huawei cloud builds three bridges for them

"Share" devaxpress asp Net v22.1 latest version system environment configuration requirements
随机推荐
Summarize the level of intelligent manufacturing discussion [macro understanding]
笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
Apache MINA框架「建议收藏」
股票软件开发
Log in to Baidu online disk with cookies (websites use cookies)
Oracle database download, installation, use tutorial and problem summary
From Tong Dai to "Tong Dai" and then to brand, the beauty of sudden profits has changed and remained unchanged
基于海思3559 高效率的 0延时 0拷贝 qt播放器方案
PMP adopts the latest exam outline, here is [agile project management]
Share 25 useful JS single line codes
[artifact] screenshot + mapping tool snipaste
Binarysearch basic binary search
VMware 虚拟机下载、安装和使用教程
CarSim仿真快速入门(十四)—CarSim-Simulink联合仿真
tiktok如何破零播放?
RepVGG网络中重参化网络结构解读【附代码】
wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac
Prescan quick start to master the special functions of prescan track editing in lecture 18
CarSim simulation quick start (XIV) - CarSim Simulink joint simulation
4、Nacos 配置中心源码解析之 服务端启动