如何删除 pandas 单元格中两个数字之间的字母字符?

How to remove a Alphabetical char between two numbers in a cell in pandas?

目标:我有一个名为 Resolution 的专栏。你可以在图片中看到什么。假设第一个单元格 1600 x 900 我需要去掉 x 以获得整数值。所以结果应该是 1600 900。我该怎么做?

我试过在线搜索我找不到答案。

尝试使用 replace:

df['Best_Resolution'] = df['Best_Resolution'].str.replace('x', ' ')

或者如果您希望该值为整数:

df['Best_Resolution'] = (
    df['Best_Resolution'].str.replace('x', '')
    .astype(int)
)

如果存在无法转换为整数的值,可能会失败。