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 Clean Up Your Data

data science basic

Please example this code ,I am getting it. What is the aim of writing this code? what output do we expect?

1 Answer

check out this code (the output of the code may be different but the aim of the code is to filter the search_term):

from s2v5 import * def pattern_match(list,search_term): array = [] for row in list: if search_term in row[7]: array.append(row[1]) return array

reader = pattern_match(my_csv, b'cashmere') print(reader)

above code filters out the 'search_term' and returns the id of the ties having that particular search in the form an array. Note here the string search_term is passed in the form a byte object, because the file is read in byte objects.