Bill Z
Bill Z

Reputation: 23

TypeError: '>' not supported between instances of 'str' and 'int' in Python

For each program, how many people have a Programming Skill knowledge of less than 4? Report one row for each existing program.

df1['ProgSkills'<4].groupby(by=df1['Program']).count()

Error message:

TypeError: '<' not supported between instances of 'str' and 'int'

Data frame:

Data frame

Upvotes: 0

Views: 99

Answers (1)

DeepSpace
DeepSpace

Reputation: 81684

df1['ProgSkills'<4]

This literally compares the string ProgSkills to the number 4.

You meant to do

df1[df1['ProgSkills']<4]

Which will compare each value in the ProgSkills column to the number 4.

Upvotes: 1

Related Questions