Questions tagged [pandas-apply]

Applies Python functions to rows or columns of a pandas dataframe, which may or may not result in aggregation.

Pandas apply available in DataFrame and Series classes is the equivalent of map in many functional languages like Haskell or Scala. It calls the function given in the argument for each element/row/column (depending on other parameters).

More detailed documentation can be found in:

170 questions
0
votes
1 answer

TypeError: Numpy.float64 object is not callable iterating rows pandas dataframe

Currently working on a dataset using pandas. Don't have much experience with this sort of stuff so any help would be greatly appreciated. dataset (shown below): The table shows ratings associated with different segments grouped by year. I am…
MapPeddler
  • 53
  • 9
-1
votes
1 answer

How to use the apply function on a dataframe for retrieving a particular column?

I wrote the following code for downloading the dataset and apply EDA functions on the DataFrame url =…
-1
votes
2 answers

How do I use apply in pandas with a function that requires two vectors

I want to pass vector columns to apply in a pandas dataframe, here is a simplification: def mae(y_true, y_pred): return (y_true - y_pred).abs().mean() df = pd.DataFrame({"y_true": [1.1, 2, 3], "y_pred": [2, 2.5, 3]}) df[df.y_true >…
Luis dQ
  • 80
  • 5
-1
votes
3 answers

Pandas Dataframe Apply - lambda function appending to list

I have a list contained in a column of a pandas dataframe. And I want to append the value in the "price_label" column to the list. I'm currently using a function i've made to do this, but is it the best way? I feel like I am missing something…
Lewis Morris
  • 1,916
  • 2
  • 28
  • 39
-1
votes
1 answer

Cluster Rows in Data Subgroups

I have a dataset df of object components in 3-d space - each ID represents an object which has various components: ID Comp x y z A 1 2 2 1 A 2 2 1 -1 A 3 -10 1 …
1 2 3
11
12