Skip to content
Advertisement

Tag: dataframe

Manipulating DataFrame

I have the following dataframe df where there are 3 columns: Date, value and topic. I want to create a new dataframe df1 where the topic is the column and is indexed by day, and each topic has its own value per day. My problem is that I don’t know how to match the value to the topic per day.

Pandas apply function to each row by calculating multiple columns

I have been stacked by an easy question, and my question title might be inappropriate. I want to calculate (df.amount * df.con)/df.groupby(‘name’).agg({‘amount’:’sum’}).reset_index().loc(df.name==i).amount) (Sorry, this line will return error, but what I want is to calculate total concentration (under each name) based on each ingredient amount and ingredient con. Here is my code: output: Any short-cut for this calculation? Thanks ahead.

importing for loop output to another for loop

I am facing problem while importing the output of a for-loop to another for loop. My python script Actually facing problem in this line of code e = {d[0]: c, d[1]:[2.0,2.0]}, where value of c should be different but by this script i am getting repeated value. Answer Your problem is that you keep over writting the value if c

Advertisement