You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修正market列的连写数据格式?求对应实现语法方案

如何修正数据表中market列的连写数据格式?

原始数据表:

market
SocialMediaAdvertising
SocialInvesting
FinancialExchanges
CloudMagement
VentureCapital

期望输出:

market
Social Media Advertising
Social Investing
Financial Exchanges
Cloud Magement
Venture Capital

解决方案

核心逻辑是在小写字母后的大写字母前插入空格,可通过正则表达式实现,以下是不同场景的具体操作:

1. Excel/Google Sheets 批量处理

在空白单元格输入公式,下拉填充即可:

=REGEXREPLACE(A2, "([a-z])([A-Z])", "$1 $2")

2. Python Pandas 处理数据集

import pandas as pd

# 读取或构造数据表
df = pd.DataFrame({
    'market': ['SocialMediaAdvertising', 'SocialInvesting', 'FinancialExchanges', 'CloudMagement', 'VentureCapital']
})

# 批量修正格式
df['market'] = df['market'].str.replace(r'([a-z])([A-Z])', r'\1 \2', regex=True)

print(df)

3. SQL 数据库更新(以MySQL/PostgreSQL为例)

执行更新语句直接修正表中数据:

UPDATE your_table_name
SET market = REGEXP_REPLACE(market, '([a-z])([A-Z])', '$1 $2');

注:SQL Server需使用自定义函数或拆分拼接逻辑实现类似效果

内容的提问来源于stack exchange,提问作者Jermaine Anne Latina

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 03:35:20