Skip to content

Tag: pandas

Merge timestamp column in pandas

I have a log file that has large number of columns and I would like to merge timestamp columns into one as shown in the example below Note: Single ID can have multiple similar processes e.g. multiple A in an ID Trying with melt on pandas but it seem I am missing something here Answer IIUC, you can use melt

How to cross-reference data in Pandas dataframes?

I’m working with data that has two separate IDs per item. When we pull data from most sources, we get a PLU/SKU—however, in one of our sources, we get an item number from our on-prem point-of-sale system. To solve this by hand, we have a master list that contains both the PLU and item number for each it…

python find the nearest nonzero element in df column

I have df: I want to write a function to fill 0 values.I want for each id(for each group) , when the value in number column is zero, to search the closet non zero value in the column and return the value. for example to id 1 to fill the second and third-row with 2. If I dont have such

Find value smaller but closest to current value

I have a very large pandas dataframe that contains two columns, column A and column B. For each value in column A, I would like to find the largest value in column B that is less than the corresponding value in column A. Note that each value in column B can be mapped to many values in column A. Here’s