List comprehensions and lambda, map, filter in Python

List Comprehension : List comprehensions are easy and concise way to create new lists from already existing lists. Create a list of numbers. Below is one way to square the numbers in the list and create a new list. Using list comprehension : Output: Lambda Function : It is an expression that returns a functionContinue reading “List comprehensions and lambda, map, filter in Python”

Open and Read a file in Python

Below is an example code which reads “file.csv”. Assume it contains data from a table with table headers as it’s first row. We extract the table header with : contents_header = contents[0] We then remove the table header from dataset by slicing: contents = contents[1:] Function explore_data() prints rows read from file. It can alsoContinue reading “Open and Read a file in Python”

Design a site like this with WordPress.com
Get started