You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

表格列姓名处理:复制整行至新列并删除句号前首字母缩写

How to Clean Up Names by Removing Text Before the Last Period (and Extra Spaces)

Got it, let's tackle this name formatting task step by step. I'll cover a few common tools you might be using since this is a typical data cleanup job—Excel (with formulas or Power Query) and Python/Pandas, depending on your workflow.

Excel Formula Method (Quick for Small Datasets)

First, copy your original name column to a new column: just select the original column, hit Ctrl+C, then click the first cell of your new column and press Ctrl+V.

Once you have the duplicated column, use one of these formulas to strip everything before the last period and clean up extra spaces:

For Excel 365/2021 (Simpler Formula)

If you have the latest Excel version, use TEXTAFTER—it's built for exactly this kind of extraction:

=TRIM(TEXTAFTER(A1,".",-1))
  • TEXTAFTER(A1,".",-1) grabs the text after the last occurrence of "." in cell A1
  • TRIM() removes any leading/trailing spaces that might be left after the period

For Older Excel Versions

If you're on an older version without TEXTAFTER, use this nested formula:

=TRIM(RIGHT(SUBSTITUTE(A1,".",REPT(" ",LEN(A1))),LEN(A1)))

Let me break this down so you understand what's happening:

  • SUBSTITUTE(A1,".",REPT(" ",LEN(A1))) replaces every "." in the name with a string of spaces that's the same length as the original name
  • RIGHT(...,LEN(A1)) takes the last N characters (where N is the length of the original name)—this effectively isolates the text that was after the last "."
  • TRIM() cleans up any extra spaces

Power Query Method (Better for Large Datasets)

If you're dealing with a lot of rows, Power Query is more efficient and avoids dragging formulas down:

  1. Select your data range, go to the Data tab, and click From Table/Range (make sure your data has headers)
  2. In Power Query Editor, right-click your original name column and select Duplicate Column
  3. Select the duplicated column, go to the Transform tab, click Split ColumnBy Delimiter
  4. Choose "." as the delimiter, then under Split at, select Right-most delimiter
  5. You'll now have two columns from the split—delete the first one (it has everything before the last period)
  6. Select the remaining column, go to the Transform tab, click Trim to remove extra spaces
  7. Click Close & Load to bring the cleaned data back to Excel

Python/Pandas Method (For Data Analysis Workflows)

If you're working with a dataset in Python, use Pandas to do this in one line:

import pandas as pd

# Assume your dataframe is named df, and the name column is called "Full_Name"
df["Cleaned_Name"] = df["Full_Name"].str.split(".", n=-1).str[-1].str.strip()
  • str.split(".", n=-1) splits each name into parts using "." as the separator
  • str[-1] picks the last part of the split (the text after the final period)
  • str.strip() removes any leading/trailing whitespace

内容的提问来源于stack exchange,提问作者BHeerschop

火山引擎 最新活动