Collapse Multiple Columns in Python Pandas

Mukul Latiyan
Updated on 28-Sep-2023 14:46:52

2K+ Views

Pandas is a popular data manipulation library in Python that is widely used for working with structured data. One of the common tasks when working with data is to clean and transform it in order to prepare it for analysis. Sometimes, the data might contain multiple columns that have similar information or are related to each other. In such cases, it might be useful to collapse these columns into a single column for easier analysis or visualization. Pandas provides several methods to collapse multiple columns into a single column. In this tutorial, we will explore these methods in detail and ... Read More

Circle of Squares Using Python Turtle

Mukul Latiyan
Updated on 28-Sep-2023 14:40:32

2K+ Views

The Circle of Squares is a fascinating geometric pattern that can be created using Python's turtle graphics library. This pattern consists of a circle of squares that are evenly spaced around its circumference, with each square rotated at an angle relative to the previous square. This creates a mesmerizing visual effect that can be customized to suit any color scheme or size. In this tutorial, we will explore how to create the Circle of Squares pattern using Python's turtle library, step by step. We will also discuss different customization options that can be applied to create unique variations of the ... Read More

Print Numbers with Alternate Bit Pattern in Range 1 to N

Divya Sahni
Updated on 28-Sep-2023 14:26:29

194 Views

Alternate bit pattern implies the positioning of 0’s and 1’s in a number at an alternate position i.e. no two 0s or 1’s are together. For example, 10 in binary representation is (1010)2 which has an alternate bit pattern as 0’s and 1’s are separated by each other. Problem Statement Given an integer, N. Find all the integers in the range 1 to N where the bit pattern of the integer is alternating. Example 1 Input: 10 Output: 1, 2, 5, 10 Explanation $\mathrm{(1)_{10} = (1)_2, (2)_{10} = (10)_2, (5)_{10} = (101)_2, (10)_{10} = (1010)_2}$ Example 2 Input: ... Read More

Jacobsthal and Jacobsthal Lucas Numbers

Divya Sahni
Updated on 28-Sep-2023 14:19:17

433 Views

Jacobsthal Numbers Lucas sequence 𝑈𝑛(𝑃, 𝑄) where P = 1 and Q = -2 are called Jacobsthal numbers. The recurrence relation for Jacobsthal numbers is, $$\mathrm{𝐽_𝑛 = 0\: 𝑓𝑜𝑟 \: 𝑛 = 0}$$ $$\mathrm{𝐽_𝑛 = 1\: 𝑓𝑜𝑟 \: 𝑛 = 1}$$ $$\mathrm{𝐽_𝑛 = 𝐽_𝑛−1 + 2𝐽_{𝑛−2}\: 𝑓𝑜𝑟 \: 𝑛 > 1}$$ Following are the Jacobsthal numbers − 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, …. Jacobsthal-Lucas Numbers Complementary Lucas sequence $\mathrm{𝑉_𝑛(𝑃, 𝑄)}$ where P = 1 and Q = -2 are called JacobsthalLucas numbers. The recurrence relation for Jacobsthal-Lucas numbers is, $\mathrm{𝐽_𝑛}$ = ... Read More

Top 10 phpMyAdmin Alternatives

Shirjeel Yunus
Updated on 28-Sep-2023 14:17:46

1K+ Views

What is phpMyAdmin? phpMyAdmin is a software application which can be used to administer MySQL on the internet. The platform can be used to do a lot of things in MariaDB and MySQL. The operations include the management of databases and their parts like tables, columns, indexes, relations, permissions, users, and many more. The app can also be used to execute any SQL statement. A wide variety of documentation is also available and users are also allowed to update the wiki pages of the app. Why phpMyAdmin Alternatives? It supports only MariaDB and MySQL It is not ... Read More

Increment a Number by 1 by Manipulating the Bits

Divya Sahni
Updated on 28-Sep-2023 14:03:06

2K+ Views

Bit manipulation applies logical operations on a bit stream using bitwise operators like AND(&), OR(|), NOT(~), XOR(^), Left Shift() to get a required result. Using bitwise operators is beneficial as we can manipulate individual bits and they are faster than other operators. Problem Statement Given a number. Increment or add the number by 1 using bitwise operators only. (Don’t use arithmetic operators like ‘+’ , ‘-’, ‘*’ or’/’ ) Approach 1: Using One’s Complement / NOT Operator Bitwise complement / One’s complement is implemented using the NOT(~) Operator. For a number n, a bitwise complement of n i.e. ~n = ... Read More

Best Aptoide Alternatives

Shirjeel Yunus
Updated on 28-Sep-2023 13:17:24

2K+ Views

What is Aptoide? Aptoide is a platform that consists of a lot of applications which can be downloaded on Android devices. It can be said that Aptoide is an alternative to Google Play Store. Aptoide came into picture in 2009 which consists of applications for smartphones and tablets. An Android application which is used to access stores is used to run Aptoide. This is an open-source platform and apps included here are available for free. If you are unable to find any app on the Google Play Store, you can access Aptoide and search for it. Why Aptoide Alternatives? ... Read More

Sum of Fourth Powers of First N Natural Numbers

Divya Sahni
Updated on 28-Sep-2023 12:07:35

2K+ Views

The fourth power of a number x is x raised to the power 4 or x4. Natural numbers are all positive integers excluding zero. Thus, the sum of the fourth powers of the first N natural numbers is − $\mathrm{Sum = 1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$ This article describes some approaches for finding the sum using minimum time and space complexity. Problem Statement Given the number N, find the sum $\mathrm{1^4 + 2^4 + 3^4 + 4^4 + … + N^4}$. Example 1 Input: 3 Output: 98 Explanation $\mathrm{Sum = 1^4 + ... Read More

Convert Python Date String mm-dd-yyyy to Datetime

Rajendra Dharmkar
Updated on 28-Sep-2023 02:02:47

14K+ Views

In Python, you can convert a string to date object using the strptime() function. Provide the date string and the format in which the date is specified.  Example import datetime date_str = '29/12/2017' # The date - 29 Dec 2017 format_str = '%d/%m/%Y' # The format datetime_obj = datetime.datetime.strptime(date_str, format_str) print(datetime_obj.date())OutputThis will give the output −2017-12-29

Find Only Monday's Date with Python

Vikram Chiluka
Updated on 28-Sep-2023 01:59:51

11K+ Views

In this article, we will show you how to find only Monday's date using Python. We find the last Monday, next Monday, nth Monday's dates using different methods− Using timedelta() function Using relativedelta() function to get Last Monday Using relativedelta() function to get next Monday Using relativedelta() function to get next nth Monday Using timedelta() function to get previous nth Monday Method 1: Using timedelta Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task − Use the import keyword, to import the, datetime (To work with Python dates and times) module. Use ... Read More

Advertisements