Found 27104 Articles for Server Side Programming

Python - Filter odd elements from value lists in dictionary

Tapas Kumar Ghosh
Updated on 17-Jul-2023 18:08:28

514 Views

The dictionary is a popular data type in Python that has a key with value pair and doesn’t allow duplicates. To filter the odd elements it has some built-in functions like items(), filter(), lambda, and, the list() will be used to Filter odd elements from value lists in the dictionary. The odd elements of the list are those elements that are not divisible by 2. For example − The given list, [10, 22, 21, 19, 2, 5] After filtering the odd elements from the list: The final result becomes [10, 22, 2] (These are the elements that are divisible by ... Read More

Filter Range Length Tuples in Python

Tapas Kumar Ghosh
Updated on 17-Jul-2023 17:59:50

326 Views

A range length is defined by representing range of values that follow the start and end point along with the length. In Python, there are some built-in functions like list(), append(), filter(), and, lambda which can be used to solve the problem based on Filter Range Length Tuples. This type of problem statement normally helps to build the logic of filtering tool. Syntax The following syntax is used in the examples − len() The len() is the built-in method in Python that returns the length of the object. append() The append method in Python is used to add ... Read More

How to Convert a Matrix to a Dictionary in Python

Tapas Kumar Ghosh
Updated on 17-Jul-2023 17:47:51

303 Views

The matrix is defined by arranging rows and columns to form an array. The values of a matrix in rows and columns either be characters or integers. There are various method names- dictionary comprehension, for loop, enumerate, and, zip() that will be used to Convert a Matrix to a Dictionary in Python. Using a for Loop and Dictionary Comprehension The program uses the for loop that will iterate the length of the matrix by applying dictionary comprehension. This helps the conversion of the matrix into a dictionary. Example In the following example, we will show the name values of matrix ... Read More

Convert Snake Case String to Camel Case using Python

Tapas Kumar Ghosh
Updated on 17-Jul-2023 17:43:29

1K+ Views

The snake case string is the naming convention where words are instead separated by an underscore(‘-’). The Camel case is defined by two or more words connected together without spaces and the first letter of each word being capitalized. There are various built-in methods in Python such as split(), join(), and, re.sub() that can be used to convert Snake Case String to Camel Case using Python. Let’s take an example of this − Snake Case String − hello_world(having separator i.e. underscore ‘_’) Camel Case String − helloWorld(when we convert the Snake case into Camel case it allows the second ... Read More

Convert Lists to Nested Dictionary in Python

Tapas Kumar Ghosh
Updated on 17-Jul-2023 17:42:11

438 Views

The list is defined by an ordered sequence of elements whereas the nested dictionary defines the dictionary include another dictionary. The nested dictionary is required when we want to store large data in a big dictionary. In Python, we have some built-in functions like reduce() and zip() that Convert Lists into Nested Dictionary. For example- Dictionary data communicate the structural content of data which is easier to understand. Syntax The following syntax is used in the examples − reduce() This built-in function in Python follows the functools module to perform a specific operation on lists. zip() The zip() ... Read More

How to select a range of rows from a dataframe in PySpark?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 17:19:48

751 Views

The dataframe in PySpark is defined by a shared collection of data that can be used to run in computer machines and structurize the data into rows and columns format. The range of rows defines a horizontal line(set of multiple values according to condition) in the dataset. In general, the range sets the lowest and highest values. In Python, we have some built-in functions like filter(), where(), and, collect() to select a range of rows from a dataframe in PySpark. Syntax The following syntax is used in the examples − createDataFrame() This is a built-in method in Python ... Read More

How to slice a PySpark dataframe in two row-wise dataframe?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:52:47

574 Views

PySpark dataframe is defined as a collection of distributed data that can be used in different machines and generate the structure data into a named column. The term slice is normally used to represent the partitioning of data. In Python, we have some built-in functions like limit(), collect(), exceptAll(), etc that can be used to slice a PySpark dataframe in two row-wise dataframe. Syntax The following syntax is used in the examples − limit() This is a built-in method in Python that can be used to set the range of rows by specifying the integer value. subtract() The ... Read More

How to Set Axis Limits bokeh?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:49:05

203 Views

Bokeh is a built-in Python library that makes a highly interactive graph for data visualization. Generally, web developers use this library to build powerful dashboards, live app applications, and, simple charts on the web. In Python, we have some bokeh built-in functions like figure(), vbar(), y_range(), etc. to Set Axis Limits bokeh. The various field used this library such as Data Scientists, Data Engineers, and, Web Developers. Syntax The following syntax is used in the examples − figure() The figure is a built-in method of bokeh library and it is known for a subclass of plot that simply create ... Read More

How to set axes labels & limits in a Seaborn plot?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:46:23

7K+ Views

Creating the plots using Seaborn will adjust the labels and axes limitations to make the plots more understandable. The axes labels are the names we can provide to the x and y axes so that others can understand what the plots show. We can focus on select areas of the data that are significant by altering the axes' limitations. Seaborn includes straightforward methods for setting axis labels and boundaries that allow us to make our plots more informative. In Python, we have some built-in functions like xlabel(), ylabel(), xlim(), and, ylim() that can be used to set the axes labels ... Read More

How to set the tab size in Text widget in Tkinter?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 16:44:39

547 Views

The Python Tkinter module allows us to develop graphical user interfaces (GUIs) and show main windows on the screen. The value of a Tkinter window screen from its ability to improve the user experience and enable the interactivity of user's programs. In Python, we have some built-in functions like Tk(), Text(), pack(), etc. that can be used to set the tab size in Text widget in tkinter. Syntax The following syntax is used in the examples − Tk() This is a built-in function of tkinter module that helps to display the main window and manage all the components of ... Read More

Advertisements