我已经解析了一些数据,当您执行df['text'].values时,示例单元格如下所示
['[\'Color is not claimed as a feature of the mark.\', \'"BRICKS"\', \'The mark consist of the stylized word "PIX" with an image of a toy block to the right and the stylized word "BRIX" appearing below.\', "Children\'s toys, namely, toy building and construction blocks and interlocking toy building and construction blocks", \'PIX BRICKS\']'],
dtype=object)然而,我想将数据分成多个列表,类似于这种格式,但每个列表包含的信息都在一个单元格中‘颜色’不是一个特征,‘砖块’...
20523203 Color is not claimed as a feature of the mark.
20523204 "BRICKS"
20523205 The mark consist of the stylized word "PIX" wi...
20523206 Children's toys, namely, toy building and cons...
20523207 PIX BRICKS对如何做到这一点有什么建议吗?
发布于 2021-09-02 16:23:27
In [6]: data
Out[6]: ['[\'Color is not claimed as a feature of the mark.\', \'"BRICKS"\', \'The mark consist of the stylized word "PIX" with an image of a toy block to the right and the stylized word "BRIX" appearing below.\', "Children\'s toys, namely, toy building and construction blocks and interlocking toy building and construction blocks", \'PIX BRICKS\']']
In [7]: # you need to remove [ and ] from the data
In [8]: clean_data = data[0].strip('[').strip(']')
In [9]: clean_data
Out[9]: '\'Color is not claimed as a feature of the mark.\', \'"BRICKS"\', \'The mark consist of the stylized word "PIX" with an image of a toy block to the right and the stylized word "BRIX" appearing below.\', "Children\'s toys, namely, toy building and construction blocks and interlocking toy building and construction blocks", \'PIX BRICKS\''
In [10]: # then split the data
In [11]: clean_data.split(',')
Out[11]:
["'Color is not claimed as a feature of the mark.'",
' \'"BRICKS"\'',
' \'The mark consist of the stylized word "PIX" with an image of a toy block to the right and the stylized word "BRIX" appearing below.\'',
' "Children\'s toys',
' namely',
' toy building and construction blocks and interlocking toy building and construction blocks"',
" 'PIX BRICKS'"]https://stackoverflow.com/questions/69033753
复制相似问题