似乎[x]代表列表中的状态。您可以尝试使用iterrows. 像这样的东西:state = None # initialize as None, in case something goes wrong city = Nonerowlist = []for idx, row in df.iterrows(): # get the state if '[x]' in row['Col']: state = row['Col'] continue # now, get the cities city = row['Col'] rowlist.append([state, city])df2 = pd.DataFrame(rowlist)这假设您的初始数据框被调用df并且列名是Col,并且仅当城市后跟州时才有效,这似乎是从您的数据样本中得出的。