Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Python Articles - Page 810 of 1048
 
			
			693 Views
Pandas is a famous python library that Is extensively used for data processing and analysis in python. In this article we will see how to use the .iloc method which is used for reading selective data from python by filtering both rows and columns from the dataframe.iloc method processes data by using integer based indexes which may or may not be part of the original data set. The first row is assigned index 0 and second and index 1 and so on. Similarly, the first column is index 0 and second is index 1 and so on.The Data SetBelow is ... Read More
 
			
			391 Views
Sometimes we may have a need to refine a given list by eliminating the duplicate elements in it. This can be achieved by using a combination of various methods available in python standard library.with set and splitThe split method can be used to segregate the elements for duplicate checking and the set method is used to store the unique elements from the segregated list elements.Example# initializing list listA = [ 'xy-xy', 'pq-qr', 'xp-xp-xp', 'dd-ee'] print("Given list : ", listA) # using set() and split() res = [set(sub.split('-')) for sub in listA] # Result print("List after duplicate removal ... Read More
 
			
			417 Views
The dir() function returns list of the attributes and methods of any object like functions , modules, strings, lists, dictionaries etc. In this article we will see how to use the dir() in different ways in a program and for different requirements.Only dir()When we print the value of the dir() without importing any other module into the program, we get the list of methods and attributes that are available as part of the standard library that is available when a python program is initialized.ExamplePrint(dir())OutputRunning the above code gives us the following result −['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', ... Read More
 
			
			2K+ Views
Multiplying two lists in python can be a necessity in many data analysis calculations. In this article we will see how to multiply the elements of a list of lists also called a nested list with another list.Using LoopsIn this approach we design tow for loops, one inside another. The outer loop keeps track of number of elements in the list and the inner loop keeps track of each element inside the nested list. We use the * operator to multiply the elements of the second list with respective elements of the nested list.Example Live DemolistA = [[2, 11, 5], [3, ... Read More
 
			
			189 Views
Sometimes when creating a matrix using python we may need to control how many times a given element is repeated in the resulting matrix. In this articled we will see how to create a matrix with required number of elements when the elements are given as a list.Using zipWe declare a list with elements to be used in the matrix. Then we declare another list which will hold the number of occurrences of the element in the matrix. Using the zip function we can create the resulting matrix which will involve a for loop to organize the elements.Example Live DemolistA = ... Read More
 
			
			606 Views
Pandas is a very widely used python library for data processing and data analysis. In this article we will see how we we can create pandas dataframe from given python dictionaries and lists.From dictionary with listsDictionaries are key value pairs. If we take a python dictionary which has key and a list as a value then we can directly use the DataFrame method on the given dictionary to create the pandas data frame.Example Live Demoimport pandas as pd # Dictionary for Exam Schedule Exam_Schedule = { 'Exam Day': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'], 'Exam Subject': ['Chemisry', 'Physics', 'Maths', 'English', 'Biology'], ... Read More
 
			
			305 Views
Pandas creates data frames to process the data in a python program. In this article we will see how we can add a new column to an existing dataframe based on certain conditions.The Given Data FrameBelow is the given pandas DataFrame to which we will add the additional columns. It describes the Days and Subjects of an examination.Example Live Demoimport pandas as pd # Lists for Exam subjects and Days Days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] Sub = ['Chemisry', 'Physics', 'Maths', 'English', 'Biology'] # Dictionary for Exam Schedule Exam_Subjects = {'Exam Day': Days, ... Read More
 
			
			991 Views
Python’s wide availability of libraries enables it to interact with Microsoft excel which is a very widely used data processing tool. In this article we will see how we can use the module named xlsxwriter to create and write into a excel file. It cannot write into existing excel file.Writing to Each CellWe can write to each cell of an excel sheet by writing to the name of the cell. In the below example we create a workbook and then ass a worksheet to it. Finally write to the cells of the worksheet using the write() method.Exampleimport xlsxwriter # ... Read More
 
			
			316 Views
The Dataframe in pandas can be created using various options. One of the option is to take a dictionary and convert it to a Dataframe. In this article we will see how to take three lists of equal length and convert them to a pandas dataframe using a python dictionary.Uisng Lists and DictionaryIn this approach we have the lists declared individually. Then each of them is used as a value for the appropriate key inside a dictionary definition. Finally the pandas method called pd.Dataframe is applied to the dictionary.Example Live Demoimport pandas as pd # Lists for Exam schedule Days ... Read More
 
			
			3K+ Views
Python Tkinter can be used to create all kinds of GUI programs for the web and desktop. In this article we will see how to create a digital clock displaying hour, minute and seconds live.We use the time module to import the method strftime which displays the time in Hour, minute and seconds format. We create a canvas to hold these values. We refresh the values of strftime after every 200 milli seconds. We define a recursive function to achieve this.Exampleimport time from tkinter import * canvas = Tk() canvas.title("Digital Clock") canvas.geometry("350x200") canvas.resizable(1, 1) label = Label(canvas, font=("Courier", 30, 'bold'), ... Read More