agentsclimarketplace

Dashboard pandas

Skill morning-start/agent-skills/tool/dashboard/dashboard-pandas

AI 编程助手的专业技能库,涵盖 30+ 技能,按 6 类组织

Install
npx -y skills add morning-start/agent-skills --skill dashboard-pandas

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Pandas 数据处理技能,掌握数据读取、清洗、转换和聚合,为数据看板提供高质量的数据源

SKILL.md

3.9 KB, as published. Nobody here has run it

Dashboard Pandas

任务目标

  • 本 Skill 用于:使用 Pandas 进行数据处理和准备
  • 能力包含:数据读取、数据清洗、数据转换、数据聚合
  • 触发条件:需要处理外部数据或准备看板数据源时

操作步骤

数据读取

import pandas as pd

# CSV 文件
df = pd.read_csv('data.csv')

# Excel 文件
df = pd.read_excel('data.xlsx', sheet_name='Sheet1')

# JSON
df = pd.read_json('data.json')

# SQL
from sqlalchemy import create_engine
engine = create_engine('sqlite:///data.db')
df = pd.read_sql('SELECT * FROM table', engine)

# URL
df = pd.read_csv('https://example.com/data.csv')

数据预览

# 基本信息
df.head()           # 前5行
df.tail()           # 后5行
df.info()           # 数据类型和缺失值
df.describe()       # 统计描述
df.shape            # 行列数
df.columns          # 列名列表
df.dtypes           # 每列数据类型

数据选择

# 列选择
df['name']              # 单列
df[['name', 'age']]    # 多列

# 行选择
df.iloc[0:10]          # 位置索引
df.loc[0:10]          # 标签索引

# 条件筛选
df[df['age'] > 18]                    # 单条件
df[(df['age'] > 18) & (df['city'] == 'Beijing')]  # 多条件

# 查询语法
df.query('age > 18 and city == "Beijing"')

数据清洗

# 缺失值处理
df.isnull().sum()           # 统计缺失值
df.dropna()                 # 删除缺失行
df.fillna(0)                # 填充缺失值
df['col'].fillna(df['col'].mean())  # 用均值填充

# 重复值处理
df.duplicated().sum()       # 统计重复
df.drop_duplicates()       # 删除重复

# 类型转换
df['date'] = pd.to_datetime(df['date'])
df['price'] = df['price'].astype(float)

数据转换

# 列重命名
df.rename(columns={'old': 'new', 'col2': 'name2'})

# 添加/修改列
df['total'] = df['price'] * df['quantity']
df['year'] = df['date'].dt.year

# 删除列
df.drop(columns=['col1', 'col2'])

# 排序
df.sort_values('price', ascending=False)
df.sort_index()

# 字符串处理
df['name'].str.lower()
df['name'].str.strip()
df['code'].str.contains('ABC')

数据聚合

# 分组统计
df.groupby('category')['price'].sum()
df.groupby('category').agg({'price': 'sum', 'quantity': 'mean'})

# 透视表
pd.pivot_table(df, values='sales', index='region', columns='quarter', aggfunc='sum')

# 交叉表
pd.crosstab(df['A'], df['B'])

# 时间序列重采样
df.set_index('date').resample('M')['sales'].sum()

数据合并

# 合并
pd.merge(df1, df2, on='key', how='inner')

# 拼接
pd.concat([df1, df2], axis=0)   # 纵向
pd.concat([df1, df2], axis=1)   # 横向

# 追加
df1.append(df2)

常用统计

# 描述统计
df['price'].count()
df['price'].mean()
df['price'].median()
df['price'].std()
df['price'].quantile([0.25, 0.5, 0.75])

# 累计计算
df['cumsum'] = df['value'].cumsum()
df['pct_change'] = df['value'].pct_change()

# 排名
df['rank'] = df['score'].rank(ascending=False)

数据导出

# CSV
df.to_csv('output.csv', index=False)

# Excel
df.to_excel('output.xlsx', index=False)

# JSON
df.to_json('output.json', orient='records')

# 剪贴板
df.to_clipboard()

资源索引

注意事项

  • 读取大文件时使用 chunksize 分块读取
  • 使用 query() 提高复杂筛选可读性
  • 避免在循环中修改 DataFrame,使用向量化操作
  • 处理时间序列时先 set_index 再操作

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.