Group Pandas DataFrame by Month in Python

AmitDiwan
Updated on 09-Sep-2021 11:41:00

2K+ Views

We will group Pandas DataFrame using the groupby. Select the column to be used using the grouper function. We will group month-wise and calculate sum of Registration Price monthly for our example shown below for Car Sale Records.At first, let’s say the following is our Pandas DataFrame with three columns −dataFrame = pd.DataFrame(    {       "Car": ["Audi", "Lexus", "Tesla", "Mercedes", "BMW", "Toyota", "Nissan", "Bentley", "Mustang"],     "Date_of_Purchase": [       pd.Timestamp("2021-06-10"),       pd.Timestamp("2021-07-11"),       pd.Timestamp("2021-06-25"),         ... Read More

Check Missing Dates in Pandas

AmitDiwan
Updated on 09-Sep-2021 11:13:53

2K+ Views

To check missing dates, at first, let us set a dictionary of list with date records i.e. Date of Purchase in our example −# dictionary of lists d = {'Car': ['BMW', 'Lexus', 'Audi', 'Mercedes', 'Jaguar', 'Bentley'],    'Date_of_purchase': ['2020-10-10', '2020-10-12', '2020-10-17', '2020-10-16', '2020-10-19', '2020-10-22']}Now, create a dataframe from the above dictionary of lists −dataFrame = pd.DataFrame(d)Next, set it as index −dataFrame = dataFrame.set_index('Date_of_purchase')Use to_datetime() to convert string to DateTime object −dataFrame.index = pd.to_datetime(dataFrame.index) Display remaining dates in a range −k = pd.date_range( start="2020-10-10", end="2020-10-22").difference(dataFrame.index);ExampleFollowing is the code −import pandas as pd # dictionary of lists d = {'Car': ['BMW', ... Read More

Fuzzy Matching on Pandas DataFrame Column using Python

AmitDiwan
Updated on 09-Sep-2021 10:32:35

2K+ Views

We will match words in the first DataFrame with words in the second DataFrame. For closest matches, we will use threshold. We took the value of threshold as 70 i.e., match occurs when the strings at more than 70% close to each other.Let us first create Dictionaries and convert to pandas dataframe −# dictionaries d1 = {'Car': ["BMW", "Audi", "Lexus", "Mercedes", "Rolls"]} d2 = {'Car': ["BM", "Audi", "Le", "MERCEDES", "Rolls Royce"]} # convert dictionaries to pandas dataframes df1 = pd.DataFrame(d1) df2 = pd.DataFrame(d2)Now, convert dataframe column to list of elements for fuzzy matching −myList1 = df1['Car'].tolist() myList2 = ... Read More

Count Frequency of Itemsets in Pandas DataFrame

AmitDiwan
Updated on 09-Sep-2021 08:47:43

346 Views

Use the Series.value_counts() method to count frequency of itemsets. At first, let us create a DataFrame −# Create DataFrame dataFrame = pd.DataFrame({'Car': ['BMW', 'Mercedes', 'Lamborghini', 'Audi', 'Mercedes', 'Porsche', 'Lamborghini', 'BMW'], 'Place': ['Delhi', 'Hyderabad', 'Chandigarh', 'Bangalore', 'Hyderabad', 'Mumbai', 'Mumbai', 'Pune'], 'UnitsSold': [95, 80, 80, 75, 92, 90, 95, 50 ]})Count the frequency of column car using the value_counts() method −# counting frequency of column Car count1 = dataFrame['Car'].value_counts() print("Count in column Car") print(count1)In the same way, count the frequency of other columns. Following is the complete code to count frequency of itemsets in Pandas DataFrame ... Read More

Different Approaches to Congestion Control

Bhanu Priya
Updated on 09-Sep-2021 08:24:29

13K+ Views

The presence of congestion means the load is greater than the resources available over a network to handle. Generally we will get an idea to reduce the congestion by trying to increase the resources or decrease the load, but it is not that much of a good idea.Approaches to Congestion ControlThere are some approaches for congestion control over a network which are usually applied on different time scales to either prevent congestion or react to it once it has occurred.Let us understand these approaches step wise as mentioned below −Step 1 − The basic way to avoid congestion is to ... Read More

Services Provided to Transport Layer by Network Layer

Bhanu Priya
Updated on 09-Sep-2021 08:19:18

11K+ Views

The network layer is concerned with getting packets from the source all the way to the destination with minimal cost. Unlike the data link layer which has more important goals like just moving frames from one end of a wire to another. The network layer is the lowest layer that deals with end-to-end transmission.Network Layer Design issuesNetwork layer Design issues are as follows −Store and forward packets switchingServices provided to the transport layerImplementation of connectionless servicesImplementation of connection oriented servicesComparison of virtual-circuit datagram networksNow let us see one of the design issues of the network layer.Services provided to the transport ... Read More

What is Physical Layer Coding Violation

Bhanu Priya
Updated on 09-Sep-2021 08:15:36

5K+ Views

Data link layer translates the physical layers raw bit stream into discrete messages called frames. Now the question is how can a frame be transmitted, so the receiver can recognize the start and end frame?TechniquesThe techniques we used to find the start and end frame are −Character countFlag byte with byte stuffingStarting and ending flag with bit stuffingEncoding Violation.Now let us see the Physical layer encoding violation technique.Physical layer encoding violationThis framing method is used only in those networks in which encoding on the physical medium contain some redundancy.Some LANs encode each bit of data by using two physical bits ... Read More

What is the Character Count? Explain with an Example

Bhanu Priya
Updated on 09-Sep-2021 08:14:31

13K+ Views

Data link layer translates the physical layers raw bit stream into discrete messages called frames. Now the question is how can a frame be transmitted, so the receiver can recognize the start and end frame?TechniquesThe techniques we used to find the start and end frame are −Character countFlag byte with byte stuffingStarting and ending flag with bit stuffingEncoding Violation.Now let us see the character count technique.Character CountFirst framing method uses a field in the header to specify the number of characters in the frame. When the data link layer at the destination sees the character count, it knows how many ... Read More

Elementary Data Link Layer Protocols

Bhanu Priya
Updated on 09-Sep-2021 08:09:51

31K+ Views

Elementary Data Link protocols are classified into three categories, as given below −Protocol 1 − Unrestricted simplex protocolProtocol 2 − Simplex stop and wait protocolProtocol 3 − Simplex protocol for noisy channels.Let us discuss each protocol one by one.Unrestricted Simplex ProtocolData transmitting is carried out in one direction only. The transmission (Tx) and receiving (Rx) are always ready and the processing time can be ignored. In this protocol, infinite buffer space is available, and no errors are occurring that is no damage frames and no lost frames.The Unrestricted Simplex Protocol is diagrammatically represented as follows −Simplex Stop and Wait protocolIn ... Read More

What is Pass Band Transmission in Computer Networks

Bhanu Priya
Updated on 09-Sep-2021 08:05:03

2K+ Views

Digital Modulation is the process of converting between bits and signals.Transmission MechanismsThe various modulation schemes result in various transmission mechanisms which are as follows −Baseband transmission.Passband transmission.Multiplexing TechniquesSharing of a transmission channel by various signals is called multiplexing. The different multiplexing techniques are as follows −Time division multiplexing.Frequency division multiplexing.Code division multiplexing.Now, let us discuss one of the digital modulation schemes.Passband TransmissionPassband transmission is the transmission after shifting the baseband frequencies to some higher frequency range using modulation. It is used for long distances.Steps for Passband TransmissionLet us understand the Passband transmission step by step.Step 1 − Generally, we want ... Read More

Advertisements