data-manipulation

Pandas Groupby only same ID and when column value is false

Pandas Groupby only same ID and when column value is false Question: I have the following problem I am trying to solve currently. A dataframe with a lot of numerical columns consisting out of a "serial_number" column that act as ID. A column "update" that is either True or False. And also some numerical columns …

Total answers: 1

Pandas drop duplicates based on one group and keep the last value

Pandas drop duplicates based on one group and keep the last value Question: I have a dataframe: import pandas as pd data = pd.DataFrame({"col1": ["a", "a", "a", "a", "a", "a"], "col2": [0,0,0,1,1, 1], "col3": [1,2,3,4,5, 6]}) data col1 col2 col3 0 a 0 1 1 a 0 2 2 a 0 3 3 a 1 …

Total answers: 2

Python – Pandas DataFrame manipulation

Python – Pandas DataFrame manipulation Question: I’ve got a DataFrame called product with a list of orders, products, and quantities for each product. Here’s a screenshot: I need to make a new DataFrame that has a row for each product name and two more columns with the sum of products ordered (basically a sum on …

Total answers: 2

Filter rows from a grouped data frame based on string columns

Filter rows from a grouped data frame based on string columns Question: I have a data frame grouped by multiple columns but in this example it would be grouped only by Year. Year Animal1 Animal2 0 2002 Dog Mouse,Lion 1 2002 Mouse 2 2002 Lion 3 2002 Duck 4 2010 Dog Cat 5 2010 Cat …

Total answers: 2

Dataframe add buisness days according to multiple features

Dataframe add buisness days according to multiple features Question: I have a quite big data-frame with different products, locations, sold_value and the according date. I want to manipulate the DF in the way that each product for its according location gets dates values according to buisness day freq. As next step i want the sold_value …

Total answers: 1

List is getting changed when manipulated inside function

List is getting changed when manipulated inside function Question: I have a function that is designed to recursively look for values in an array of objects and return a string of all variables with a similar y0. This all works fine, however, when I manipulate the array it manipulates the array that has been inputted …

Total answers: 1

Applying Functions in Python

Applying Functions in Python Question: I am an R User that is trying to learn more about Python. I found this Python library that I would like to use for address parsing: https://github.com/zehengl/ez-address-parser I was able to try an example over here: from ez_address_parser import AddressParser ap = AddressParser() result = ap.parse("290 Bremner Blvd, Toronto, …

Total answers: 2

Calculating 15mins data from Cumulative Sums

Calculating 15mins data from Cumulative Sums Question: I came up with a problem. I have real-time production data with Machine Codes [M] column, which has DateTime stamps [DateTime] with cumulative sums [Cumulative] column. From the original data, I created 15mins time intervals by flooring the DateTime column. To problem is, I’d like to take latest …

Total answers: 1