Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从标记行中提取单个标记?蟒蛇熊猫_Python_Sql_Pandas_Dataframe_Analysis - Fatal编程技术网

Python 如何从标记行中提取单个标记?蟒蛇熊猫

Python 如何从标记行中提取单个标记?蟒蛇熊猫,python,sql,pandas,dataframe,analysis,Python,Sql,Pandas,Dataframe,Analysis,3300行 我需要创建一个新的单列,每行带有一个标记您必须拆分然后分解数据帧 df['Tags'] = df['Tags'].astype('str') for i in range(len(df)): df.at[i, 'Tags'] = df[i, df['Tags'].strip('><').split('><')] df.explode('Tags') df['Tags']=df['Tags'].astype('str') 对于范围内的i(len(

3300行


我需要创建一个新的单列,每行带有一个标记

您必须拆分然后分解数据帧

df['Tags'] = df['Tags'].astype('str')

for i in range(len(df)):
     df.at[i, 'Tags'] = df[i, df['Tags'].strip('><').split('><')]

df.explode('Tags')
df['Tags']=df['Tags'].astype('str')
对于范围内的i(len(df)):
df.at[i,'Tags']=df[i,df['Tags'])条带('>0.25+)和列
Tags
用于列表:

df1 = (df.assign(Tags = df['Tags'].str.strip('><').str.split('><'))
         .explode('Tags')
         .reset_index(drop=True))

df1=(df.assign(Tags=df['Tags']].str.strip)('>除非绝对必要,否则不要将信息作为图像共享。请参阅:。我们需要更多信息。这些数据是什么,从何而来?您显然没有阅读熊猫文档,请这样做。您的解决方案没有运行