datadrivenconstruction

Pandas Construction Analysis

資料分析v2.1.0
作者:datadrivenconstruction更新於 2026-05-11共 2 個版本 · 最新版本釋出於 2026-02-15pandas-construction-analysis@clawhub_datadrivenconstruction/pandas-construction-analysis
資料清洗報表生成指標監控#Data Analysis

據 AlphaMoat 統計,截至 2026-09,Pandas Construction Analysis 累計下載 2,754 次、獲 3 個星標,在全部 5,078 個 AI 技能中排名第 3,909 位,在「資料分析」分類(399 個)中排名第 294 位。

累計安裝
163
累計下載
2754
星標
3
全站排名
#3,909
全站前 77% · 「資料分析」前 74%
平台累計安裝累計下載星標評論
ClawHub ↗7926112-
SkillHub ↗16327543—

各平台的計數口徑不同,統計時間不一致。

這個技能是做什麼的

該技能介紹對結構化施工資料進行篩選、分組、聚合、工程量計算、資料集合併和報告生成。技能卡提醒分析可能讀取或匯出使用者指定路徑中的檔案,生成的程式碼或摘要也可能不適用於具體專案資料。請明確輸入與匯出路徑,避免覆蓋重要檔案,並在用於專案決策前檢查程式碼、輸入和結果。 需要 Python 與 Pandas,處理 Excel 另需對應引擎。計算前對應實際欄位名稱、單位、缺少值與連接鍵;範例假設已有整理好的表格匯出,並非原生 BIM 模型解析。

資料釋出於 2026-10-27

可以用來做什麼

  • 篩選和彙總 BIM 構件資料
  • 計算工程量並合併多個資料集
  • 生成結構化分析報告或匯出建議

什麼時候用

  • 需要使用 Pandas 整理施工或 BIM 表格資料時
  • 已確認檔案路徑和輸出檔名,並驗證分析結果適用於當前資料時

示例提示詞

以下是根據技能文件生成的示例,不代表實際執行結果。

只分析指定的 BIM 匯出檔案,展示使用的篩選和計算步驟;不要覆蓋檔案,並在寫出任何匯出前先列出目標路徑。

月度資料趨勢

累計下載2754
1447214928512026-03 · 累計下載 15442026-05 · 累計下載 19822026-06 · 累計下載 21382026-07 · 累計下載 23522026-08 · 累計下載 25202026-09 · 累計下載 275426-0326-09
星標3
2332026-03 · 星標 22026-05 · 星標 32026-06 · 星標 32026-07 · 星標 32026-08 · 星標 32026-09 · 星標 326-0326-09

2026-09 起統計方法調整:同名技能按作者分別統計,並覆蓋全部技能。圖中虛線為調整前的月份,與之後的資料不直接比較,也不計算跨越調整的增長。

月份累計下載環比星標
2026-092754—3
2026-082520+7.1%3
2026-072352+10.0%3
2026-062138+7.9%3
2026-051982—3
2026-031544—2

SKILL.md 原文

以下是作者釋出的原始檔案,按純文字顯示,本站未做修改或稽核;其中的連結不可點選,命令請核實後再執行。抓取於 2026-10-23。

13 KB · ClawHub v2.1.0
---
name: "pandas-construction-analysis"
description: "Comprehensive Pandas toolkit for construction data analysis. Filter, group, aggregate BIM elements, calculate quantities, merge datasets, and generate reports from structured construction data."
homepage: "https://datadrivenconstruction.io"
metadata: {"openclaw": {"emoji": "🐼", "os": ["darwin", "linux", "win32"], "homepage": "https://datadrivenconstruction.io", "requires": {"bins": ["python3"]}}}
---
# Pandas Construction Data Analysis

## Overview

展開全部(共 446 行)
Based on DDC methodology (Chapter 2.3), this skill provides comprehensive Pandas operations for construction data processing. Pandas is the Swiss Army knife for data analysts - handling everything from simple data filtering to complex aggregations across millions of rows.

**Book Reference:** "Pandas DataFrame и LLM ChatGPT" / "Pandas DataFrame and LLM ChatGPT"

> "Используя Pandas, вы можете управлять и анализировать наборы данных, намного превосходящие возможности Excel. В то время как Excel способен обрабатывать до 1 миллиона строк данных, Pandas может без труда работать с наборами данных, содержащими десятки миллионов строк."
> — DDC Book, Chapter 2.3

## Quick Start

```python
import pandas as pd

# Read construction data
df = pd.read_excel("bim_export.xlsx")

# Basic operations
print(df.head())           # First 5 rows
print(df.info())           # Column types and memory
print(df.describe())       # Statistics for numeric columns

# Filter structural elements
structural = df[df['Category'] == 'Structural']

# Calculate total volume
total_volume = df['Volume'].sum()
print(f"Total volume: {total_volume:.2f} m³")
```

## DataFrame Fundamentals

### Creating DataFrames

```python
import pandas as pd

# From dictionary (construction elements)
elements = pd.DataFrame({
    'ElementId': ['E001', 'E002', 'E003', 'E004'],
    'Category': ['Wall', 'Floor', 'Wall', 'Column'],
    'Material': ['Concrete', 'Concrete', 'Brick', 'Steel'],
    'Volume_m3': [45.5, 120.0, 32.0, 8.5],
    'Level': ['Level 1', 'Level 1', 'Level 2', 'Level 1']
})

# From CSV
df_csv = pd.read_csv("construction_data.csv")

# From Excel
df_excel = pd.read_excel("project_data.xlsx", sheet_name="Elements")

# From multiple Excel sheets
all_sheets = pd.read_excel("project.xlsx", sheet_name=None)  # Dict of DataFrames
```

### Data Types in Construction

```python
# Common data types for construction
df = pd.DataFrame({
    'element_id': pd.Series(['W001', 'W002'], dtype='string'),
    'quantity': pd.Series([10, 20], dtype='int64'),
    'volume': pd.Series([45.5, 32.0], dtype='float64'),
    'is_structural': pd.Series([True, False], dtype='bool'),
    'created_date': pd.to_datetime(['2024-01-15', '2024-01-16']),
    'category': pd.Categorical(['Wall', 'Slab'])
})

# Check data types
print(df.dtypes)

# Convert types
df['quantity'] = df['quantity'].astype('float64')
df['volume'] = pd.to_numeric(df['volume'], errors='coerce')
```

## Filtering and Selection

### Basic Filtering

```python
# Single condition
walls = df[df['Category'] == 'Wall']

# Multiple conditions (AND)
large_concrete = df[(df['Material'] == 'Concrete') & (df['Volume_m3'] > 50)]

# Multiple conditions (OR)
walls_or_floors = df[(df['Category'] == 'Wall') | (df['Category'] == 'Floor')]

# Using isin for multiple values
structural = df[df['Category'].isin(['Wall', 'Column', 'Beam', 'Foundation'])]

# String contains
insulated = df[df['Description'].str.contains('insulated', case=False, na=False)]

# Null value filtering
incomplete = df[df['Cost'].isna()]
complete = df[df['Cost'].notna()]
```

### Advanced Selection

```python
# Select columns
volumes = df[['ElementId', 'Category', 'Volume_m3']]

# Query syntax (SQL-like)
result = df.query("Category == 'Wall' and Volume_m3 > 30")

# Loc and iloc
specific_row = df.loc[0]                    # By label
range_rows = df.iloc[0:10]                  # By position
specific_cell = df.loc[0, 'Volume_m3']      # Row and column
subset = df.loc[0:5, ['Category', 'Volume_m3']]  # Range with columns
```

## Grouping and Aggregation

### GroupBy Operations

```python
# Basic groupby
by_category = df.groupby('Category')['Volume_m3'].sum()

# Multiple aggregations
summary = df.groupby('Category').agg({
    'Volume_m3': ['sum', 'mean', 'count'],
    'Cost': ['sum', 'mean']
})

# Named aggregations (cleaner output)
summary = df.groupby('Category').agg(
    total_volume=('Volume_m3', 'sum'),
    avg_volume=('Volume_m3', 'mean'),
    element_count=('ElementId', 'count'),
    total_cost=('Cost', 'sum')
).reset_index()

# Multiple grouping columns
by_level_cat = df.groupby(['Level', 'Category']).agg({
    'Volume_m3': 'sum',
    'Cost': 'sum'
}).reset_index()
```

### Pivot Tables

```python
# Create pivot table
pivot = pd.pivot_table(
    df,
    values='Volume_m3',
    index='Level',
    columns='Category',
    aggfunc='sum',
    fill_value=0,
    margins=True,           # Add totals
    margins_name='Total'
)

# Multiple values
pivot_detailed = pd.pivot_table(
    df,
    values=['Volume_m3', 'Cost'],
    index='Level',
    columns='Category',
    aggfunc={'Volume_m3': 'sum', 'Cost': 'mean'}
)
```

## Data Transformation

### Adding Calculated Columns

```python
# Simple calculation
df['Cost_Total'] = df['Volume_m3'] * df['Unit_Price']

# Conditional column
df['Size_Category'] = df['Volume_m3'].apply(
    lambda x: 'Large' if x > 50 else ('Medium' if x > 20 else 'Small')
)

# Using np.where for binary conditions
import numpy as np
df['Is_Large'] = np.where(df['Volume_m3'] > 50, True, False)

# Using cut for binning
df['Volume_Bin'] = pd.cut(
    df['Volume_m3'],
    bins=[0, 10, 50, 100, float('inf')],
    labels=['XS', 'S', 'M', 'L']
)
```

### String Operations

```python
# Extract from strings
df['Level_Number'] = df['Level'].str.extract(r'(\d+)').astype(int)

# Split and expand
df[['Building', 'Floor']] = df['Location'].str.split('-', expand=True)

# Clean strings
df['Category'] = df['Category'].str.strip().str.lower().str.title()

# Replace values
df['Material'] = df['Material'].str.replace('Reinforced Concrete', 'RC')
```

### Date Operations

```python
# Parse dates
df['Start_Date'] = pd.to_datetime(df['Start_Date'])

# Extract components
df['Year'] = df['Start_Date'].dt.year
df['Month'] = df['Start_Date'].dt.month
df['Week'] = df['Start_Date'].dt.isocalendar().week
df['DayOfWeek'] = df['Start_Date'].dt.day_name()

# Calculate duration
df['Duration_Days'] = (df['End_Date'] - df['Start_Date']).dt.days

# Filter by date range
recent = df[df['Start_Date'] >= '2024-01-01']
```

## Merging and Joining

### Merge DataFrames

```python
# Elements data
elements = pd.DataFrame({
    'ElementId': ['E001', 'E002', 'E003'],
    'Category': ['Wall', 'Floor', 'Column'],
    'Volume_m3': [45.5, 120.0, 8.5]
})

# Unit prices
prices = pd.DataFrame({
    'Category': ['Wall', 'Floor', 'Column', 'Beam'],
    'Unit_Price': [150, 80, 450, 200]
})

# Inner join (only matching)
merged = elements.merge(prices, on='Category', how='inner')

# Left join (keep all elements)
merged = elements.merge(prices, on='Category', how='left')

# Join on different column names
result = df1.merge(df2, left_on='elem_id', right_on='ElementId')
```

### Concatenating DataFrames

```python
# Vertical concatenation (stacking)
all_floors = pd.concat([floor1_df, floor2_df, floor3_df], ignore_index=True)

# Horizontal concatenation
combined = pd.concat([quantities, costs, schedule], axis=1)

# Append new rows
new_elements = pd.DataFrame({'ElementId': ['E004'], 'Category': ['Beam']})
df = pd.concat([df, new_elements], ignore_index=True)
```

## Construction-Specific Analyses

### Quantity Take-Off (QTO)

```python
def generate_qto_report(df):
    """Generate Quantity Take-Off summary by category"""
    qto = df.groupby(['Category', 'Material']).agg(
        count=('ElementId', 'count'),
        total_volume=('Volume_m3', 'sum'),
        total_area=('Area_m2', 'sum'),
        avg_volume=('Volume_m3', 'mean')
    ).round(2)

    # Add percentage column
    qto['volume_pct'] = (qto['total_volume'] /
                          qto['total_volume'].sum() * 100).round(1)

    return qto.sort_values('total_volume', ascending=False)

# Usage
qto_report = generate_qto_report(df)
qto_report.to_excel("qto_report.xlsx")
```

### Cost Estimation

```python
def calculate_project_cost(elements_df, prices_df, markup=0.15):
    """Calculate total project cost with markup"""
    # Merge with prices
    df = elements_df.merge(prices_df, on='Category', how='left')

    # Calculate base cost
    df['Base_Cost'] = df['Volume_m3'] * df['Unit_Price']

    # Apply markup
    df['Total_Cost'] = df['Base_Cost'] * (1 + markup)

    # Summary by category
    summary = df.groupby('Category').agg(
        volume=('Volume_m3', 'sum'),
        base_cost=('Base_Cost', 'sum'),
        total_cost=('Total_Cost', 'sum')
    ).round(2)

    return df, summary, summary['total_cost'].sum()

# Usage
detailed, summary, total = calculate_project_cost(elements, prices)
print(f"Project Total: ${total:,.2f}")
```

### Material Summary

```python
def material_summary(df):
    """Summarize materials across project"""
    summary = df.groupby('Material').agg({
        'Volume_m3': 'sum',
        'Weight_kg': 'sum',
        'ElementId': 'nunique'
    }).rename(columns={'ElementId': 'Element_Count'})

    summary['Volume_Pct'] = (summary['Volume_m3'] /
                              summary['Volume_m3'].sum() * 100).round(1)

    return summary.sort_values('Volume_m3', ascending=False)
```

### Level-by-Level Analysis

```python
def analyze_by_level(df):
    """Analyze construction quantities by building level"""
    level_summary = df.pivot_table(
        values=['Volume_m3', 'Cost'],
        index='Level',
        columns='Category',
        aggfunc='sum',
        fill_value=0
    )

    level_summary['Total_Volume'] = level_summary['Volume_m3'].sum(axis=1)
    level_summary['Total_Cost'] = level_summary['Cost'].sum(axis=1)

    return level_summary
```

## Data Export

### Export to Excel with Multiple Sheets

```python
def export_to_excel_formatted(df, summary, filepath):
    """Export with multiple sheets"""
    with pd.ExcelWriter(filepath, engine='openpyxl') as writer:
        df.to_excel(writer, sheet_name='Details', index=False)
        summary.to_excel(writer, sheet_name='Summary')

        pivot = pd.pivot_table(df, values='Volume_m3',
                               index='Level', columns='Category')
        pivot.to_excel(writer, sheet_name='By_Level')

# Usage
export_to_excel_formatted(elements, qto_summary, "project_report.xlsx")
```

### Export to CSV

```python
# Basic export
df.to_csv("output.csv", index=False)

# With encoding for special characters
df.to_csv("output.csv", index=False, encoding='utf-8-sig')

# Specific columns
df[['ElementId', 'Category', 'Volume_m3']].to_csv("volumes.csv", index=False)
```

## Performance Tips

```python
# Use categories for string columns with few unique values
df['Category'] = df['Category'].astype('category')

# Read only needed columns
df = pd.read_csv("large_file.csv", usecols=['ElementId', 'Category', 'Volume'])

# Use chunking for very large files
chunks = pd.read_csv("huge_file.csv", chunksize=100000)
result = pd.concat([chunk[chunk['Category'] == 'Wall'] for chunk in chunks])

# Check memory usage
print(df.memory_usage(deep=True).sum() / 1024**2, "MB")
```

## Quick Reference

| Operation | Code |
|-----------|------|
| Read Excel | `pd.read_excel("file.xlsx")` |
| Read CSV | `pd.read_csv("file.csv")` |
| Filter rows | `df[df['Column'] == 'Value']` |
| Select columns | `df[['Col1', 'Col2']]` |
| Group and sum | `df.groupby('Cat')['Vol'].sum()` |
| Pivot table | `pd.pivot_table(df, values='Vol', index='Level')` |
| Merge | `df1.merge(df2, on='key')` |
| Add column | `df['New'] = df['A'] * df['B']` |
| Export Excel | `df.to_excel("out.xlsx", index=False)` |

## Resources

- **Book**: "Data-Driven Construction" by Artem Boiko, Chapter 2.3
- **Website**: https://datadrivenconstruction.io
- **Pandas Docs**: https://pandas.pydata.org/docs/

## Next Steps

- See `llm-data-automation` for generating Pandas code with AI
- See `qto-report` for specialized QTO calculations
- See `cost-estimation-resource` for detailed cost calculations

「資料分析」分類下的熱門技能

AdMapix資料分析

AdMapix 的取數層:把廣告與應用相關的查詢轉成介面呼叫,只回原始 JSON。

↓ 36.6萬★ 304fly0pants
Tavily Search資料分析

透過 Tavily 搜尋公開網頁,並回傳含連結與摘要的結構化結果。

↓ 12.2萬★ 286Xiaoran Li
Data Analysis資料分析

把資料庫、表格與匯出的原始資料變成可決策結論的資料分析技能。

↓ 10.1萬★ 244Iván
Stock Analysis資料分析

用 Yahoo Finance 資料做股票與加密貨幣分析、組合跟蹤的技能。

↓ 7.5萬★ 299udiedrichsen
Stock Watcher資料分析

管理本地自選股清單,並按代碼彙總同花順行情與近期表現的技能。

↓ 6.5萬★ 122Robin797860
全國招標中標查詢及分析【知了標訊】資料分析

全網招中標資料查詢與分析助手。當用戶涉及以下任何場景時,必須使用此SKILL:查詢招標/中標公告、搜尋標訊、查詢臨期/即將到期專案、商機預測、推薦潛在投標供應商、分析公司主營業務/歷史中標、查詢公司上下游合作客戶與供應商、分析競爭對手/競對企業、查詢Top採購單位/Top中標單位/Top中標品牌、招中標資料統計分析(按月/季/年/省份/品牌等維度)、查詢品牌型號歷史中標單價/價格趨勢、市場分析/行業分析/採購尋源/渠道拓展等採購與投標相關場景。即使使用者沒有提到「知了標訊」,只要涉及招投標、採購、中標、供應商、競爭對手等關鍵詞,都應使用本SKILL。

↓ 5.6萬★ 13user_98035bfb
Blogwatcher資料分析

用命令列監控部落格與 RSS/Atom 源的更新。

↓ 5.4萬★ 75Peter Steinberger
Model Usage資料分析

彙總 Codex 或 Claude 按模型計費的使用成本。

↓ 5萬★ 114Peter Steinberger

datadrivenconstruction 的其他技能

資料月份:2026-09 · 下載/星標/安裝數聚合自公開技能註冊庫(ClawHub、SkillHub),按月更新。口徑說明見資料方法。