# Origin

## Chapter 1: A Fresh Graduate's Dilemma

Tom had just graduated from college and landed a job in the marketing department of a mid-sized company. Amid his excitement, he quickly faced his first challenge: his boss asked him to organize a complex sales data report.

Looking at the dense Excel spreadsheet before him, Tom felt overwhelmed. In college, he had only learned basic Office operations, and he was completely at a loss when faced with such a complex data processing task.

## Chapter 2: The Struggle of Self-Learning

"Don't worry, all newcomers face this situation," his colleague Sarah reassured him. "I was the same way when I started. I gradually got the hang of it after teaching myself some Excel tricks."

Over the next few months, Tom began to teach himself Excel. He learned some basic formulas and mastered the use of pivot tables. Gradually, he became capable of handling simple data analysis tasks.

## Chapter 3: Hitting a Skill Ceiling

However, as his work deepened, Tom realized that mastering these skills was far from enough. Sometimes, he needed to process thousands of rows of data, and Excel would become excruciatingly slow. He still couldn't handle more complex data analysis tasks.

Tom heard that some colleagues were learning VBA programming to automate Excel operations. He tried to learn it too, but found the learning curve too steep. Just as he was feeling discouraged, he heard about Python's pandas library, which could process data more efficiently.

## Chapter 4: Discovering a New Tool

"That's great!" Tom thought excitedly. But soon, he encountered a new problem: the company computers didn't have Python installed, and the IT department didn't allow employees to install software at will.

Just as Tom was at a loss, he happened to hear about a new tool called Excel Cursor. This tool combined the power of AI and could complete complex data processing tasks through simple conversations, without the need to install any additional software.

## Chapter 5: A Leap in Work Efficiency

With a "let's give it a try" attitude, Tom started using Excel Cursor. To his delight, he only needed to describe his requirements in everyday language, and the AI would automatically generate and execute the corresponding code. Complex data analysis became so simple that Tom felt like he had gained superpowers!

From then on, Tom's work efficiency greatly improved. He could not only easily complete various complex data processing tasks but also learned a lot of data analysis knowledge and skills in the process.

## Epilogue: Data Analysis in the AI Era

Excel Cursor not only changed Tom's way of working but also helped many newcomers like him find a shortcut to handling complex data. It made data analysis no longer the privilege of a few but a skill that everyone could master.

As Excel Cursor's slogan says: "Making data processing as natural as breathing." With the help of AI, complex Excel work finally became simple and fun.


# Introduction

Excel Cursor is a revolutionary data processing tool that perfectly combines the power of AI with the popularity of Excel. Through simple conversations, users can easily complete complex data analysis tasks without programming knowledge.

## 🔍 What Makes Excel Cursor Unique

Excel Cursor differs from other AI-powered spreadsheet tools in several key aspects of design philosophy and functionality:

1. **Focus on Code Generation and Execution**: Excel Cursor's core function is to generate Pandas code based on user requirements and remotely execute it to process data. This approach is both efficient and flexible, capable of handling various complex data analysis tasks.
2. **No Automatic Insight Generation**: Unlike some AI tools, Excel Cursor doesn't automatically generate data insights for you. We believe that valuable insights come from users' deep understanding of their own data and business. Excel Cursor's goal is to help you implement your own analytical ideas more efficiently, not to replace your thinking process.
3. **No Data Generation**: Excel Cursor doesn't bulk generate new data based on table contents. We focus on processing and analyzing existing data rather than creating new data. This ensures processing speed and efficiency while avoiding the generation of fictitious data that could mislead decision-making.

## 🧙‍♀️ Language Models and Prompts Used

* Currently using OpenAI's gpt-4o-mini model and Anthropic's claude-3-haiku, as they offer faster response times and are well-suited for the current tasks.
* Prompts will be published in the future; they are still being optimized.

## 🌟 Core Features

### 1. 🤖 Intelligent Data Processing

* **Natural Language Interaction**: Describe your data processing needs using everyday language
* **AI Code Generation**: Automatically convert your requirements into precise Pandas code
* **Code Explanation**: Provide detailed explanations for generated code, helping users understand the processing logic

### 2. 💻 Online Code Execution

* **Real-time Running**: Instantly execute generated code and quickly view processing results
* **Interactive Debugging**: Make real-time adjustments and optimizations based on execution results
* **Visualization Output**: Support various charts and data visualizations for intuitive presentation of analysis results

### 3. 📥 Excel Spreadsheet Export

* **One-click Export**: Easily export processed data as Excel spreadsheets with simple operations
* **Format Preservation**: Retain the format settings of original data to ensure exported results are visually appealing and practical
* **Big Data Support**: Capable of processing and exporting large datasets, meeting data needs of various scales

Excel Cursor is not just a data processing tool, but your intelligent data assistant. Whether you're a data analysis novice or a professional, Excel Cursor can help you process data more efficiently and intelligently, making data analysis as natural as breathing.

Start using Excel Cursor and experience the new era of AI-driven data analysis!


# Monthly Sales Breakdown

Analyze monthly sales by product category

## Sample Data

![](/files/MQGxLKkbQIEcYwTd4Nal)

## Prompt

> Calculate the sales volume of each Sub-Category for each month in 2016, with one row for each Category data, showing the months in columns, and the first two columns being Category and Sub-Category.

## Excel Cursor Response

![](/files/dgADYfjYcCro6gpFQZyl)

## Result

![](/files/r5ihhrbmzutq9l4EIgwv)


# Multi-table Data Stats

Perform data analysis by linking multiple tables together.

## Sample Data

![](/files/MQGxLKkbQIEcYwTd4Nal) ![](/files/7wgvzVDcOhJvAH4cQg2d)

## Prompt

> Match the Order IDs in the Returns table with the ones in the Orders table, count how many returns each customer made, and list their ID and name.

## Excel Cursor Response

![](/files/heZ4GteVJ71LUyWHyQln)

## Result

![](/files/jEMZulQywXwsO8yM3CLb)


# Order Profit Statistics

Calculate the total profit amount for each year based on order data.

## Sample Data

![](/files/MQGxLKkbQIEcYwTd4Nal)

## Prompt

> Help me calculate from the order table, how much profit each Customer made in 2014, 2015, and 2016 respectively.

## Excel Cursor Response

![](/files/lS0VJnefJ5kz1jRu3xv4)

## Result

![](/files/lBT0pKy17znrEQCcVsSU)


# 由来

## 第一章：职场新人的困境

小李刚刚大学毕业，进入了一家中型公司的市场部。兴奋之余，他很快就面临了第一个挑战：老板要求他整理一份复杂的销售数据报表。

看着眼前密密麻麻的 Excel 表格，小李顿时感到头大。大学里，他只学过最基础的 Office 操作，面对这样复杂的数据处理任务，他完全不知所措。

## 第二章：自学的艰辛

"别担心，新人都会遇到这种情况。"同事小王安慰道，"我当初也是这样，后来自学了一些 Excel 技巧才慢慢上手的。"

在接下来的几个月里，小李开始自学 Excel。他学会了一些基本公式，掌握了数据透视表的使用。渐渐地，他能够处理一些简单的数据统计工作了。

## 第三章：技能的瓶颈

但是，随着工作的深入，小李发现仅仅掌握这些还远远不够。有时候，他需要处理成千上万行的数据，Excel 就会变得异常缓慢。更复杂的数据分析任务，他还是无法胜任。

小李听说有些同事在学习 VBA 编程，可以实现 Excel 的自动化操作。他也尝试学习，但发现 VBA 的学习曲线太陡峭了。正当他感到沮丧时，他又听说了 Python 的 pandas 库可以更高效地处理数据。

## 第四章：新工具的发现

"太好了！"小李兴奋地想。但很快，他就遇到了新的问题：公司的电脑上没有安装 Python 环境，IT 部门也不允许员工随意安装软件。

就在小李为难之际，他偶然听说了一个叫 Excel Cursor 的新工具。这个工具结合了 AI 的强大功能，可以通过简单的对话来完成复杂的数据处理任务，而且不需要安装任何额外的软件。

## 第五章：工作效率的飞跃

抱着试一试的心态，小李开始使用 Excel Cursor。令他惊喜的是，他只需要用日常语言描述自己的需求，AI 就能自动生成相应的代码并执行。复杂的数据分析变得如此简单，小李感觉自己仿佛获得了超能力！

从此以后，小李的工作效率大大提高。他不仅能轻松完成各种复杂的数据处理任务，还在过程中学到了很多数据分析的知识和技巧。

## 结语：AI 时代的数据分析

Excel Cursor 不仅改变了小李的工作方式，也让许多像他一样的职场新人找到了处理复杂数据的捷径。它让数据分析不再是少数人的专利，而是人人都能掌握的技能。

正如 Excel Cursor 的口号所说："让数据处理变得如呼吸般自然。"在 AI 的帮助下，复杂的 Excel 工作终于变得简单而有趣。


# 介绍

Excel Cursor 是一款革命性的数据处理工具，它将 AI 的强大功能与 Excel 的普及性完美结合。通过简单的对话，用户可以轻松完成复杂的数据分析任务，无需编程知识。

## 🔍 Excel Cursor 的独特之处

Excel Cursor 在设计理念和功能实现上与其他 AI 处理表格工具有一些关键的不同：

1. **专注于代码生成和执行**: Excel Cursor 的核心功能是根据用户需求生成 Pandas 代码，并远程执行处理数据。这种方法既高效又灵活，能够处理各种复杂的数据分析任务。
2. **不自动生成洞察**: 与一些 AI 工具不同，Excel Cursor 不会自动为您生成数据洞察。我们相信，有价值的洞察来源于用户对自己数据和业务的深入理解。Excel Cursor 的目标是帮助您更高效地实现自己的分析想法，而不是替代您的思考过程。
3. **不进行数据生成**: Excel Cursor 不会根据表格内容批量生成新数据。我们专注于处理和分析现有数据，而不是创造新数据。这样可以确保处理速度和效率，同时避免产生可能误导决策的虚构数据。

## 🧙‍♀️ 使用的语言模型和提示词

* 目前使用 OpenAI 的 gpt-4o-mini 模型和 Anthropic 的 claude-3-haiku，因为它们有更快的响应速度，且能很好的胜任目前这份工作。
* 提示词未来会公布，目前还在优化中。

## 🌟 核心功能

### 1. 🤖 智能数据处理

* **自然语言交互**: 使用日常语言描述您的数据处理需求
* **AI 代码生成**: 自动将您的需求转换为精确的 Pandas 代码
* **代码解释**: 为生成的代码提供详细解释，帮助用户理解处理逻辑

### 2. 💻 在线代码执行

* **实时运行**: 即时执行生成的代码，快速查看处理结果
* **交互式调试**: 根据执行结果进行实时调整和优化
* **可视化输出**: 支持各种图表和数据可视化，直观展示分析结果

### 3. 📥 Excel 表格导出

* **一键导出**: 简单操作即可将处理后的数据导出为 Excel 表格
* **格式保留**: 保留原始数据的格式设置，确保导出结果美观实用
* **大数据支持**: 能够处理和导出大型数据集，满足各种规模的数据需求

Excel Cursor 不仅是一个数据处理工具，更是您的智能数据助手。无论您是数据分析新手还是专业人士，Excel Cursor 都能帮助您更高效、更智能地处理数据，让数据分析变得如呼吸般自然。

开始使用 Excel Cursor，体验 AI 驱动的数据分析新时代！


# 数据整理

根据订单购买记录表，提取出一张用户基本信息表。

![](https://github.com/svcvit/excel_cursor_docs/blob/main/images/Xnip2024-09-13_20-03-14.jpg)

> 💡 通过 AI 理解哪些字段属于用户记录，自动推断需要保留的列，同时根据会员编码去重，即可达到目的

## 示例数据

| 交易时间                | 会员名称 | 会员性别 | 会员状态      | 会员编码           | 信息完整度 | 出生日期 | 可退换货数量 | 商品名称       | 商品编码     | 支付金额  | 最后购买时间     | 最后购买金额 | 来源渠道           | 标准售价  | 活跃度  | 累计购买次数 | 累计购买金额   | 订单编码     | 退货数量 | 销售净额  | 销售数量 |
| ------------------- | ---- | ---- | --------- | -------------- | ----- | ---- | ------ | ---------- | -------- | ----- | ---------- | ------ | -------------- | ----- | ---- | ------ | -------- | -------- | ---- | ----- | ---- |
| 2024-08-20 18:15:03 | 杭源垣  | 未知   | \[50]正式会员 | PP240321689842 | 0     |      | 2      | 维生素 AD 滴剂  | 12051054 | 91.60 | 2024-08-20 | 91.6   | 上海高济余天成大药房有限公司 | 45.80 | 活跃 A | 3      | 3,352    | 22859008 | 0    | 91.60 | 2    |
| 2024-08-20 18:00:26 | 宁媚如  | 男    | \[50]正式会员 | PP181127268580 | 0     |      | 1      | 甲磺酸溴隐亭片    | 22041774 | 90.50 | 2024-08-20 | 90.5   | 高济总部           | 90.50 | 活跃 A | 6      | 3,730.9  | 22858992 | 0    | 90.50 | 1    |
| 2024-08-20 15:09:14 | 蓬妤殉  | 女    | \[50]正式会员 | PP181127269347 | 0     |      | 1      | 萘敏维滴眼液     | 13186276 | 13.97 | 2024-08-20 | 30.2   | 一德泰和药房         | 13.97 | 活跃 A | 230    | 15,987.1 | 22858897 | 0    | 13.97 | 1    |
| 2024-08-20 15:09:14 | 蓬妤殉  | 女    | \[50]正式会员 | PP181127269347 | 0     |      | 1      | 复方醋酸地塞米松乳膏 | 13187858 | 16.23 | 2024-08-20 | 30.2   | 一德泰和药房         | 16.23 | 活跃 A | 230    | 15,987.1 | 22858897 | 0    | 16.23 | 1    |

## 提示词

```
这是一份用户订单数据，请根据表头识别哪些字段和用户基本信息相关，帮我整理出来，最终生成一张用户表，注意根据会员编码去重
```

## AI 回复内容

首先，根据用户的基本信息，我们可以识别出以下与用户相关的字段：

* 会员名称
* 会员性别
* 会员状态
* 会员编码
* 出生日期
* 信息完整度

接下来，通过这些字段生成一张用户表，并根据会员编码进行去重。以下是处理步骤：

1. 从原始数据中提取与用户基本信息相关的字段。
2. 根据会员编码去重，保留唯一的用户记录。

以下是实现这些步骤的 pandas 代码：

```python
import pandas as pd

user_columns = ['会员名称', '会员性别', '会员状态', '会员编码', '出生日期', '信息完整度']
df_users = data["CRM Data"][user_columns].drop_duplicates(subset='会员编码')
df_output = df_users.reset_index(drop=True)
```

## 结果

| 会员名称 | 会员性别 | 会员状态      | 会员编码           | 出生日期 | 信息完整度 |
| ---- | ---- | --------- | -------------- | ---- | ----- |
| 杭源垣  | 未知   | \[50]正式会员 | PP240321689842 | 0    |       |
| 宁媚如  | 男    | \[50]正式会员 | PP181127268580 | 0    |       |
| 蓬妤殉  | 女    | \[50]正式会员 | PP181127269347 | 0    |       |
| 苏丰宽  | 女    | \[50]正式会员 | PP181127269016 | 0    |       |
| 贺蓉凝  | 男    | \[50]正式会员 | PP181127265499 | 0    |       |


# 数据透视表

根据用户订单记录，自动生成每人每个月花费。

![](https://github.com/svcvit/excel_cursor_docs/blob/main/images/Xnip2024-09-13_20-22-10.jpg)

> 💡 统计一下每个人每个月的消费金额，每行一条用户的数据，列需要保留会员编号和姓名，之后的列展示每个月的金额

## 示例数据

| 交易时间                | 会员名称 | 会员性别 | 会员状态      | 会员编码           | 信息完整度 | 出生日期 | 可退换货数量 | 商品名称       | 商品编码     | 支付金额  | 最后购买时间     | 最后购买金额 | 来源渠道           | 标准售价  | 活跃度  | 累计购买次数 | 累计购买金额   | 订单编码     | 退货数量 | 销售净额  | 销售数量 |
| ------------------- | ---- | ---- | --------- | -------------- | ----- | ---- | ------ | ---------- | -------- | ----- | ---------- | ------ | -------------- | ----- | ---- | ------ | -------- | -------- | ---- | ----- | ---- |
| 2024-08-20 18:15:03 | 杭源垣  | 未知   | \[50]正式会员 | PP240321689842 | 0     |      | 2      | 维生素 AD 滴剂  | 12051054 | 91.60 | 2024-08-20 | 91.6   | 上海高济余天成大药房有限公司 | 45.80 | 活跃 A | 3      | 3,352    | 22859008 | 0    | 91.60 | 2    |
| 2024-08-20 18:00:26 | 宁媚如  | 男    | \[50]正式会员 | PP181127268580 | 0     |      | 1      | 甲磺酸溴隐亭片    | 22041774 | 90.50 | 2024-08-20 | 90.5   | 高济总部           | 90.50 | 活跃 A | 6      | 3,730.9  | 22858992 | 0    | 90.50 | 1    |
| 2024-08-20 15:09:14 | 蓬妤殉  | 女    | \[50]正式会员 | PP181127269347 | 0     |      | 1      | 萘敏维滴眼液     | 13186276 | 13.97 | 2024-08-20 | 30.2   | 一德泰和药房         | 13.97 | 活跃 A | 230    | 15,987.1 | 22858897 | 0    | 13.97 | 1    |
| 2024-08-20 15:09:14 | 蓬妤殉  | 女    | \[50]正式会员 | PP181127269347 | 0     |      | 1      | 复方醋酸地塞米松乳膏 | 13187858 | 16.23 | 2024-08-20 | 30.2   | 一德泰和药房         | 16.23 | 活跃 A | 230    | 15,987.1 | 22858897 | 0    | 16.23 | 1    |

## 提示词

```
统计一下每个人每个月的消费金额，每行一条用户的数据，列需要保留会员编号和姓名，之后的列展示每个月的金额
```

## AI 回复内容

首先，根据需求，我们需要完成以下步骤：

1. 将 `交易时间` 列转换为日期格式，并提取出年份和月份。
2. 按照 `会员编码`、`会员名称`、年份和月份进行分组，并计算每个用户每个月的 `支付金额` 总和。
3. 将结果转换为宽格式，以便每个月的消费金额在不同的列中展示。

接下来是生成相应的 pandas 代码：

```python
import pandas as pd

# 将 '交易时间' 列转换为日期格式
data["CRM Data"]['交易时间'] = pd.to_datetime(data["CRM Data"]['交易时间'])

# 提取年份和月份
data["CRM Data"]['年月'] = data["CRM Data"]['交易时间'].dt.to_period('M')

# 按照会员编码、会员名称和年月分组，并计算支付金额总和
monthly_spending = data["CRM Data"].groupby(['会员编码', '会员名称', '年月'])['支付金额'].sum().reset_index()

# 将数据转换为宽格式
df_output = monthly_spending.pivot_table(index=['会员编码', '会员名称'], columns='年月', values='支付金额', fill_value=0)

# 重置索引
df_output.reset_index(inplace=True)

# 输出结果
df_output
```

## 结果

| 会员编码           | 会员名称 | 2023-08 | 2023-09 | 2023-10 | 2023-11 | 2023-12 | 2024-01 | 2024-02 | 2024-03 | 2024-04 | 2024-05 | 2024-06 | 2024-07 | 2024-08 |
| -------------- | ---- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- |
| PP181127265147 | 松波炼  | 727.4   | 0       | 0       | 0       | 78.9    | 304.5   | 119.4   | 0       | 0       | 0       | 0       | 0       | 0       |
| PP181127265153 | 汤崴弋  | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 130.2   | 0       | 0       | 0       |
| PP181127265173 | 殷晏   | 0       | 0       | 333.9   | 589.2   | 2502.3  | 168.9   | 183.7   | 136.1   | 105.1   | 333.8   | 33.6    | 629.9   | 5.9     |
| PP181127265187 | 齐悦珊  | 0       | 34.2    | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       |
| PP181127265340 | 卫锟战  | 0       | 0       | 0       | 0       | 3615.3  | 0       | 0       | 0       | 0       | 0       | 0       | 0       | 0       |


