Choose A File Starting With A Given String

Overview Problem: How to choose a file starting with a given string? Example: Consider that we have a directory with files as shown below. How will you select the files starting with “001_Jan“? Python Modules Cheat Sheet To Choose A File Starting With A Given String Choosing a file starting with a given string is … Read more

Convert Bytes To Floating Point Numbers

Summary: The struct module in Python, taken from the C programming language, lets you convert bytes to and from floating point numbers. [toc] Problem: How to convert bytes to floating point numbers? A quick look at the solution: A Brief Introduction to Struct The struct module has three main methods for data conversion: unpack(), pack() … Read more

How Do I Fill Column With One Value In Pandas?

Summary: The following approaches will help you to fill a column with one value in Pandas: df[‘col_name’] = “value” df.insert(index, ‘col_name’, ‘value’) df.loc[:, ‘col_name’] = ‘value’ df = df.assign(‘col_name’=’value’) Introduction Problem Formulation: How do I fill a column with one value in Pandas? Example: Let’s consider that we have a DataFrame as shown below: Output: … Read more

Storing Scraped Data

[toc] Introduction After scraping huge chunks of data, you need to store them in a proper format. You may want to store the data directly into a text file, or you may opt to store it in a more structured way in a csv file or an excel sheet. You may otherwise want to store … Read more

Pagination in Webscraping

❖ Disclaimer: This tutorial considers that you have the basic knowledge of web scraping. The purpose of this article is to educate you on how to scrape content from websites with pagination. The examples and theories mentioned in this tutorial are solely for educational purposes and it is considered that you will not misuse them. In case … Read more

Display The Time In A Different Time Zone

Summary: You are recommended to use the pytz library because of its efficiency and effectiveness in displaying time in a different time zone in Python. However, it would be best to understand the datetime module because it plays a massive role in date and time manipulation. Introduction Displaying the time in a different time zone can be … Read more

How to Select Rows From a DataFrame Based on Column Values

Problem Statement: Selecting rows from a Dataframe based on the column values. Introduction DataFrame (A Quick Recap) A DataFrame is a 2-dimensional data structure that is generally immutable and heterogeneous. It has labelled axes – rows and columns. A Pandas Dataframe comprises three parts: data, rows, and columns. Now let’s create a Dataframe. We are … Read more

How to Rotate Proxies in Python?

❖ Disclaimer: This tutorial considers that you have the basic knowledge of web scraping. The purpose of this article is to educate you on how to rotate proxies and avoid being blocked while web scraping. The examples and theories mentioned in this tutorial are solely for educational purposes and it is considered that you will not misuse … Read more

Save Plot to Image File Using Matplotlib

This article will look at different methods to save a plot to an image file instead of displaying it usingΒ Matplotlib. Matplotlib is a plotting library in Python that is used to create figures, shapes, and graphs.Β  Note: Before diving into the methods to save the plot to an image file, instead of displaying it using … Read more