当前位置:网站首页>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!')
边栏推荐
- Six axis sensor use learning record
- Deeplobv1 and V2
- 如何保证定制滑环质量
- PMP adopts the latest exam outline, here is [agile project management]
- 接口请求合并的3种技巧,性能直接爆表!
- CarSim仿真快速入门(十六)—CarSim传感器仿真之ADAS Sensor Objects (2)
- Shopping guide for high-end flagship projectors: dangbei X3 pro and dangbei F5 are more immersive!
- Rainbond插件扩展:基于Mysql-Exporter监控Mysql
- Univariate function integration_ Partial integral method
- How to set tiktok mobile network environment? How can tiktok break the playback volume?
猜你喜欢

Connecting to the database warning establishing SSL connection without server's identity verification is not recommended

Recommended system topic | Minet: cross domain CTR prediction

9. < tag dynamic programming and subsequence, subarray> lt.718. Longest repeated subarray + lt.1143. Longest common subsequence

一元函数积分学_分部积分法
![[wp]ctfshow-web introductory information collection](/img/22/c2e5cca918800dda9df27272eb9871.png)
[wp]ctfshow-web introductory information collection

When the V100 of mindpole 8 card is trained to 101 epochs, an error of reading data timeout is reported

UNET and mask RCNN

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

wallys//wifi6 wifi5 router IPQ6018 IPQ4019 IPQ4029 802.11ax 802.11ac

10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
随机推荐
推荐系统专题 | MiNet:跨域CTR预测
Gbase 8s UDR memory management_ 02_ mi_ dalloc
Apache MINA框架「建议收藏」
Ml programming skills:
VMware virtual machine download, installation and use tutorial
Bash does not add single quotes to your string
Oracle database download, installation, use tutorial and problem summary
RepVGG网络中重参化网络结构解读【附代码】
What is the method to load the torch pre trained model for the mindspore model finetune?
High number_ Chapter 3 learning experience and summary of multiple integral
当AI邂逅生命健康,华为云为他们搭建三座桥
Notes - record a cannotfinddatasourceexception: dynamic datasource can not find primary datasource problem solving
4、Nacos 配置中心源码解析之 服务端启动
基于海思3559 高效率的 0延时 0拷贝 qt播放器方案
Legal mix of collations for operation 'Union' (bug record)
Bash does not add single quotes to your string
When AI encounters life and health, Huawei cloud builds three bridges for them
Deeplobv1 and V2
10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
what is qml in qt