| by Arround The Web

Filter NaN Pandas

To filter out the rows having the NaN values in Python, the “dataframe” functions, such as “dataframe.notnull()”, and “dataframe.dropna()” functions are used.

Share Button
Read More
| by Arround The Web

NumPy Save Dict

To save the dictionary into a file in Python, the “dump()” function is used and the “load()” function is used to read the saved dictionary from a file.

Share Button
Read More
| by Arround The Web

Remove Special Characters from String Python

To remove special characters from the string in Python, the “isalnum()”, “replace()”, “translate()”, “filter()”, and “re.sub()” methods are used.

Share Button
Read More
| by Arround The Web

7 Different Types of Operators in Python [With Examples]

Any developer who wants to write out effective and efficient code must be familiar with using operators in Python.
The post 7 Different Types of Operators in Python [With Examples] appeared first on Linux Today.

Share Button
Read More
| by Arround The Web

Python List to Comma Separated String

To convert a Python list to a comma-separated string, apply “join()” method, “join()” with “List Comprehension” approach, “for” loop, or the “StringIO” module.

Share Button
Read More
| by Arround The Web

Python Math Exp

In Python, the “math.exp()” function of the “math” module is used to calculate the exponent power of numeric values such as “int” and “float”.

Share Button
Read More
| by Arround The Web

Python os.path.expanduser() Method

The “os.path.expanduser()” method allows us to easily expand paths that start with “~” or “~user” to the appropriate home directory path.

Share Button
Read More
| by Arround The Web

Python StringIO

In Python, the “StringIO” module is used to manipulate strings as if they were files. This module provides various methods to perform specific tasks in Python.

Share Button
Read More
| by Arround The Web

Seaborn Horizontal Bar Plot

To create, and customize the horizontal bar plot the “seaborn.barplot()” function of the “seaborn” library is used with various parameters in Python.

Share Button
Read More
| by Arround The Web

Python Write String to File

To write a string to file various methods such as the “write()” method, “with” statement, and “fileinput” module are used in Python.

Share Button
Read More
| by Arround The Web

How Do I Convert an Exception to a String in Python

To convert an exception to a string the “str()” function, “traceback.format_exc()” function, and “repr()” function is used in Python.

Share Button
Read More
| by Arround The Web

How to Unzip Files in Python

The “zipfile” module and the “shutil” module are used to unzip single or multiple files from the specified zip file in Python.

Share Button
Read More
| by Arround The Web

Python Count Characters in String

To count characters in a string in Python, apply the “len()” function, “Counter” class from the collections module, “dictionary comprehension”, etc.

Share Button
Read More
| by Arround The Web

Python Count Occurrences in List

To count the occurrences in a list in Python, apply the “count()” method, “Counter” class, “operator” module, “List Comprehension” approach, or the “for” loop.

Share Button
Read More
| by Arround The Web

Matplotlib Bold Text

The “fontweight” and “weight” parameters are used to bold a text in Matplotlib. It is used to emphasize key information and enhance visualizations.

Share Button
Read More
| by Arround The Web

Convert String to Set Python

To convert the given string to a set, various methods such as “set()” function, “add()” method, or the “set comprehension” can be used in Python.

Share Button
Read More
| by Arround The Web

How to Use Xrange in Python

The xrange() function in Python 2.x or range() function in Python 3.x is used for efficient iteration over a range of values.

Share Button
Read More
| by Arround The Web

Python Finds the Index of All Occurrences in a List

The “for” loop, “enumerate()” function, “index()” method, or the “defaultdict()” function can be used to find the index of all occurrences in a list in Python.

Share Button
Read More
| by Arround The Web

NumPy Astype

The “astype()” method of the numpy module is used to change the data type of a NumPy array into other data types such as str, int, complex, etc.

Share Button
Read More
| by Arround The Web

How Do I Check If a String Is Empty in Python

“not” operator, “len()” function, “strip()” function, “==” operator, “__eq__()” method, or “not + str.isspace()” method can check if string is empty in Python.

Share Button
Read More