Я хочу визуализировать созданный мной DataFrame из CSV-файла с пандами для школьного задания. DataFrame содержит данные о предложениях из двух разных глав книги. Я хотел бы извлечь данные из одной конкретной главы книги и создать два новых отдельных кадра данных. Поэтому я пытаюсь получить доступ ко всем строкам, содержащим «1» (как в главе 1) столбца «глава». Вот как выглядит фрейм данных:
length sentences chapter ranking
0 99 The word "house" is not a linguistic fact if b... 1 1
1 201 In an age when the study of antiquity attracte... 2 1
2 88 This can only mean that the sounds of speech a... 1 2
3 145 If you consider that whatever view we take of ... 2 2
4 75 If the involuntary cry of pain which is conven... 1 3
5 136 For it is evident we observe no footsteps in t... 2 3
6 71 The auditory centers alone may be excited; or ... 1 4
7 118 Man had studied every part of nature the miner... 2 4
8 68 The auditory symbolism may be replaced point f... 1 5
9 116 It has absorbed the thoughts of men who after ... 2 5
10 68 These symbols are in the first instance audito... 1 6
11 93 The dimensions of the science of language are ... 2 6
12 68 Naturally the particular points or clusters of... 1 7
13 91 The astronomer retains these and many other na... 2 7
14 66 It is even conceivable if not exactly likely t... 1 8
15 92 Lord Monboddo for instance admits that as yet ... 2 8
16 65 As such they may be considered an integral por... 1 9
17 89 It is counted as a science by so sound and sob... 2 9
18 63 If language can be said to be definitely "loca... 1 10
19 86 If with all these difficulties and drawbacks I... 2 10
Я попытался выбрать нужные строки с помощью этого кода и присвоить их новой переменной (глава1):
df = pd.read_csv('task1.csv')
chapter1 = df[df.chapter == '1']
Я бы хотелсоздать новый фрейм данных этих строк. Я получаю сообщение об ошибке: поэлементное сравнение не удалось;вместо этого возвращает скаляр, но в будущем будет выполнять поэлементное сравнение
Как мне решить эту ОШИБКУ?
Благодарю за помощь