Posts

Showing posts from September, 2019

[DataCamp] SOA on Python Data Science Toolbox (Part2)

Image
Main contents of this course are as follows 1. Iterators, Iterables in Detail 2. enumerate(), zip(), unzip() and using * on iterators 3. using iterators to load large files into memory 4. List comprehensions, nested list, conditionals in comprehensions 5. generators, generator expressions 6. generators, iterators for streaming data 7. iterators to load data in chunks

[DataCamp] SOA on Python Data Science Toolbox (Part1)

Image
This course was NOT as good as previous courses. Some functions and keywords, which are new, are not explained in detail before problems are suggested. However, this courses are still very good to me so far. Main contents of this course are as follows 1. Making user defined functions 2. Variable-length arguments and Nested functions 3. Lambda functions and map(), filter(), reduce() 4. Error Handling : try-except, raise

[Python] Code Example 6 - Lambda & filter function (2)

[Source Code] # Select retweets from the Twitter DataFrame: result result = filter(lambda x : x[0:2] == 'RT', tweets_df['text']) # Create list from filter object result: res_list res_list = list(result) # Print all retweets in res_list for tweet in res_list:     print(tweet) [Output] ========================================== <script.py> output:     RT @bpolitics: .@krollbondrating's Christopher Whalen says Clinton is the weakest Dem candidate in 50 years https://t.co/pLk7rvoRSn https:/…     RT @HeidiAlpine: @dmartosko Cruz video found.....racing from the scene.... #cruzsexscandal https://t.co/zuAPZfQDk3     RT @AlanLohner: The anti-American D.C. elites despise Trump for his America-first foreign policy. Trump threatens their gravy train. https:…     RT @BIackPplTweets: Young Donald trump meets his neighbor  https://t.co/RFlu17Z1eE     RT @trumpresearch: @WaitingInBagd...

[Python] Code Example 5 - Lambda & filter function (1)

[Source Code] # Create a list of strings: fellowship fellowship = ['frodo', 'samwise', 'merry', 'pippin', 'aragorn', 'boromir', 'legolas', 'gimli', 'gandalf'] # Use filter() to apply a lambda function over fellowship: result result = filter(lambda member: len(member) > 6, fellowship) # Convert result to a list: result_list result_list = list(result) # Print result_list print(result_list) [Output] ========================================== ['samwise', 'aragorn', 'boromir', 'legolas', 'gandalf']