@@ -0,0 +1,1168 @@
+import re%0Aimport pandas as pd%0Aimport toolz as tz%0A%0A%0Adef strlst_to_lststr(genres):%0A    %22%22%22Convert a string of list entries to a list of lowercase strings.%0A%0A    Examples%0A    --------%0A    %3E%3E%3E strlst_to_lststr('%5B%22Banking Hijinks%22, %22Actuarial adventure%22%5D')%0A    %5B'banking hijinks', %22actuarial adventure%22%5D%0A    %22%22%22%0A    return list(map(%0A        lambda g: g.strip().lower()%5B1:-1%5D,%0A        re.sub('%5B%5C%5B%5C%5D%5D', '', genres).split(',')))%0A%0A%0Adef to_datetime(date):%0A    %22%22%22Given a string date, return a Python datetime.date.  If only the year is%0A    given, the date is (%3Cyear%3E, 1, 1).  If the result is a null type or if an%0A    exception is raised, None is returned.%0A    %22%22%22%0A    try:%0A        ret = pd.to_datetime(date).to_pydatetime().date()%0A    except:%0A        ret = None%0A    if pd.isnull(ret):%0A        ret = None%0A    return ret%0A%0A%0Adef load(path):%0A    %22%22%22Load the CSV data, transform into an appropriate form for exploitation,%0A    and return a list of dicts%0A    %22%22%22%0A%0A    def tx(d):%0A        return tz.merge(d, %7B%0A            'genres': strlst_to_lststr(d%5B'genres'%5D),%0A            'release_date': to_datetime(d%5B'release_date'%5D)%7D)%0A%0A    return list(map(tx, pd.read_csv(path).to_dict('records')))%0A

load and transform data