import pandas as pd
import numpy as np
# Assuming 'a' is a pandas Series
a = pd.Series(['bear', 'fox', 'wolf', 'mouse'])
# Splitting the characters and stacking them as columns
split_chars = a.str.split('', expand=True).drop(0, axis=1)
# Creating 'ao' column by joining the characters
ao = a.str.cat(sep='')
# Printing the results
print(split_chars)
print(ao)
3条答案
按热度按时间pn9klfpd1#
字符串
6psbrbz92#
你可以用正则表达式(和lookarounds)
split
并展开它:字符串
split
的regex demo。或者,使用
extractall
获取每个字符,然后使用unstack
进行整形:型
输出量:
型
sxpgvts33#
另一个可能的解决方案:
字符串
输出量:
型