Browse Source

新增:水稳数据清洗重复平行项

张世豪 1 month ago
parent
commit
22a6967a61

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 8 - 0
.idea/Data_Processing.iml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="jdk" jdkName="D:\software\anaconda\envs\py38" jdkType="Python SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 16 - 0
.idea/inspectionProfiles/Project_Default.xml

@@ -0,0 +1,16 @@
+<component name="InspectionProjectProfileManager">
+  <profile version="1.0">
+    <option name="myName" value="Project Default" />
+    <inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
+      <option name="ignoredPackages">
+        <value>
+          <list size="3">
+            <item index="0" class="java.lang.String" itemvalue="opencv-python" />
+            <item index="1" class="java.lang.String" itemvalue="imageio-ffmpeg" />
+            <item index="2" class="java.lang.String" itemvalue="torch" />
+          </list>
+        </value>
+      </option>
+    </inspection_tool>
+  </profile>
+</component>

+ 6 - 0
.idea/inspectionProfiles/profiles_settings.xml

@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+  <settings>
+    <option name="USE_PROJECT_PROFILE" value="false" />
+    <version value="1.0" />
+  </settings>
+</component>

+ 7 - 0
.idea/misc.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Black">
+    <option name="sdkName" value="D:\software\anaconda\envs\py38" />
+  </component>
+  <component name="ProjectRootManager" version="2" project-jdk-name="D:\software\anaconda\envs\py38" project-jdk-type="Python SDK" />
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/Data_Processing.iml" filepath="$PROJECT_DIR$/.idea/Data_Processing.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="" vcs="Git" />
+  </component>
+</project>

+ 25 - 0
水稳数据清洗重复平行项.py

@@ -0,0 +1,25 @@
+import pandas as pd
+
+# 读取 Excel 文件
+input_file = r"C:\Users\16142\Desktop\水稳匹配原样品编码.xlsx" # 输入水稳已匹配原编码表
+output_file =r"C:\Users\16142\Desktop\水稳样品清洗重复平行项.xlsx"  # 输出文件路径
+df = pd.read_excel(input_file)
+
+# 需要取平均值的列
+columns_to_average = [
+    '水稳>5mm(%)',
+    '水稳3mm~5mm(%)',
+    '水稳2mm~3mm(%)',
+    '水稳1mm~2mm(%)',
+    '水稳0.5mm~1mm(%)',
+    '水稳0.25mm~0.5mm(%)',
+    '水稳性大团聚体总和(%)'
+]
+
+# 按"原样品编号"分组,计算每组的平均值
+df_avg = df.groupby('原样品编号', as_index=False)[columns_to_average].mean()
+df_avg['原样品编号'] = df_avg['原样品编号'].astype(str)
+# 保存结果到新的 Excel 文件
+df_avg.to_excel(output_file, index=False)
+
+print(f"处理完成,结果已保存到 {output_file}")