I have created a pandas dataframe called df using this code: import numpy as np import pandas as pd The dataframe looks like this: The columns contain some special characters (/ and @) that I need to replace with a blank space. Now, I have a list of special characters: listOfSpecialChars = ‘¬`!”£$…
Tag: pandas
Python – Anyone mind to assist in this Pandas Dataframe problem? URGENT
I am facing some difficulties using merge function in Pandas. I am looking for some kind of Vlookup formula to assist me on this. However, I couldn’t solve my problem. My data is huge and I couldn’t share here due to confidential. However, I try to came up with similar data here. Old Code New Code…
Getting a dictionnary of lists that contain element from a column using a groupby
I have a dataframe that looks like this, with 1 string column and 1 int column. I would like to get at the very end a dictionnary of lists that store all values of column B groupby A, like this : What I made to achieve this to used a groupby to get number of occurences for column_B : And
Cumulative count of column based on Month
I have a dataframe that looks like this: Code Period A 2022-04-29 A 2022-04-29 A 2022-04-30 A 2022-05-01 A 2022-05-01 A 2022-05-01 I have to create a new column, i.e., if the month ends then Count should start from 1. Below is the code that I have tried at my end. Code Period size A 2022-04-29 2 A 2022-04-30 …
how to avoid row number in read_sql output
When I use pandas read_sql to read from mysql, it returns rows with row number as first column as given below. Is this possible to avoid row numbers? Answer You can use False as the second parameter to exclude indexing. Example or Use this function to guide you You can read more about this here -> Pandas D…
Converting prices in a Pandas dataframe
So I have a dataframe with the lines corresponding to different clothing items. I have two columns with prices and the syntax looks like this: price rrp 5.00 8.00 5 7.50 5.0 9.0 I want to convert these so that prices like 5.00/5.0 are converted to 5, but values like 7.50 stay the same. I’ve tried conver…
How to find the row having the minimum values in a given pandas dataframe?
I have created a dataframe using the following code. Then I found the minimum values of each row by using It gave me the minimum value of each column, but I also want to find out that at which index the min value is available for each column. Please give a sutiable solution for finding the index of the min
checking for computers in another dataframe
I have one data frame that outputs hostname and agent_version this is named df_filter output: i have another sccm data frame called df_sccm Name check cs dataframe is in sccm df i am trying to see if my output of the first dataframe is in my second dataframe (df_sccm), when i run it, it just says false, even …
Transpose and Groupby pandas Columns
I’m looking to transpose pandas columns and apply a Groupby How can I achieve this expected output ? Answer Use DataFrame.stack for reshape with remove missing values and count values by Series.value_counts, last Series.sort_index with Series.rename_axis and Series.reset_index for 2 columns DataFrame: E…
Extracting Rows and Appending Them to the End of Other Rows
I have a dataframe containing a transaction list. What I want to do is create something like a P&L per transaction and additionally make it suitable for entry into another software. Basically, I would like to get a “Buy” transaction and find the next row with a “Sell” transaction. …