Я использую Python3 для чтения столбца из электронной таблицы Excel:
import pandas as pd
from pandas import ExcelFile
df = pd.read_excel('MWE.xlsx', sheet_name='Sheet1')
print(df)
col1 col2
0 starts normal egg, bacon
1 still none the wiser egg, sausage, bacon
2 maybe odd tastes egg, spam
3 or maybe post-war egg, bacon, spam
4 maybe for the hungry egg, bacon, sausage, spam
5 bingo spam, bacon, sausage, spam
Я хочу уменьшить col2
до единого списка слов в col2 (например, egg, bacon, ...).
df.col2.ravel()
, кажется, сокращает col2
до списка строк.
df.col2.flatten()
приводит к
AttributeError: 'Series' object has no attribute 'flatten'