Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Data Science Basics Cleaning Data Filtering Rows

Kartik Kapoor
Kartik Kapoor
256 Points

b'_silk' vs '_silk'

I was trying to get the number of silk ties. The data sample that I pass to the function is a numpy object and not a csv.reader list. When I pass '_silk' to be matched I get zero ties. When I pass b'_silk' it gives 3381 ties while the correct number is 3382. What is going on?

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

'_silk' is a unicode string in Python 3, b'_silk' is a bytes object (see docs on data types). numpy needs bytes not strings.

Is the "3381" the 0-based count": 3382 items numbered 0 through 3381?