Reading and Writing CSV Files in Python with Pandas

There are many ways of reading and writing CSV files in Python. There are a few different methods, for example, you can use Python’s built in open() function to read the CSV (Comma Separated Values) files or you can use Python’s dedicated csv module to read and write CSV files. Depending on your use-case, you can also use Python’s Pandas library to read and write CSV files. In this article, you will see how to use Python’s Pandas library to […]

Read more

Reading and Writing MS Word Files in Python via Python-Docx Module

The MS Word utility from Microsoft Office suite is one of the most commonly used tools for writing text documents, both simple and complex. Though humans can easily read and write MS Word documents, assuming you have the Office software installed, often times you need to read text from Word documents within another application. For instance, if you are developing a natural language processing application in Python that takes MS Word files as input, you will need to read MS […]

Read more

One-Hot Encoding in Python with Pandas and Scikit-Learn

Introduction In computer science, data can be represented in a lot of different ways, and naturally, every single one of them has its advantages as well as disadvantages in certain fields. Since computers are unable to process categorical data as these categories have no meaning for them, this information has to be prepared if we want a computer to be able to process it. This action is called preprocessing. A big part of preprocessing is encoding – representing every single […]

Read more

Unpacking in Python: Beyond Parallel Assignment

Introduction Unpacking in Python refers to an operation that consists of assigning an iterable of values to a tuple (or list) of variables in a single assignment statement. As a complement, the term packing can be used when we collect several values in a single variable using the iterable unpacking operator, *. Historically, Python developers have generically referred to this kind of operation as tuple unpacking. However, since this Python feature has turned out to be quite useful and popular, […]

Read more

The Singleton Design Pattern in Python

Introduction In this article, we’ll be diving into the Singleton Design Pattern, implemented in Python. As time progresses, software gets more tailored to solving specific problems in different domains. While there are many difference in the application-level of our software, some aspects of software design remain largely the same. These aspects might not remain the same for all software out there but will hold true for a lot of scenarios. Therefore, learning and understanding them will be highly beneficial in […]

Read more

Reading and Writing JSON Files in Python with Pandas

Introduction Pandas is one of the most commonly used Python libraries for data handling and visualization. The Pandas library provides classes and functionalities that can be used to efficiently read, manipulate and visualize data, stored in a variety of file formats. In this article, we’ll be reading and writing JSON files using Python and Pandas. What is a JSON File? JavaScript Object Notation (JSON) is a data format that stores data in a human-readable form. While it can be technically […]

Read more

The Bridge Design Pattern with Python

Introduction The Bridge Design Pattern is a Structural Design Pattern, which splits the abstraction from the implementation. In this article, we’ll be covering the motivation and implementation of the Bridge Design Pattern in Python. Design Patterns refer to a set of standardized practices or solutions to common architectural problems in software engineering. Motivation Behind the Bridge Design Pattern The Bridge Pattern prevents what’s called the cartesian product complexity explosion. The problem will be obvious going through an example. Suppose you’re […]

Read more

Writing to a File with Python’s print() Function

Introduction Python’s print() function is typically used to display text either in the command-line or in the interactive interpreter, depending on how the Python program is executed. However, we can change its behavior to write text to a file instead of to the console. In this article, we’ll examine the many ways we can write to a file with the print() function. Redirecting a Python’s Script Output in the Terminal The quick and dirty way to redirect a Python script’s […]

Read more

map(), filter(), and reduce() in Python with Examples

Introduction The map(), filter() and reduce() functions bring a bit of functional programming to Python. All three of these are convenience functions that can be replaced with List Comprehensions or loops, but provide a more elegant and short-hand approach to some problems. Before continuing, we’ll go over a few things you should be familiar with before reading about the aforementioned methods: What is an anonymous function/method or lambda? An anonymous method is a method without a name, i.e. not bound […]

Read more

The Factory Method Design Pattern in Python

Introduction In this article, we’ll be diving into the Factory Method Design Pattern, implemented in Python. Design Patterns define tried and tested solutions to various recurring problems in software development. They do not represent actual code, but rather ways in which we can organize our code for the optimum results. In a world of limited resources, Design Patterns help us achieve the most results with the least amount of used resources. It is also important to note that Design Patterns […]

Read more
1 876 877 878 879 880 910