Skip to content

Tag: dataframe

How to get a value in a column as an index

I assign the eligible index value to A column and then df.ffill() Now I want to use the value of A column as an index and assign the obtained value to the expcted column I try df[‘expected’]=df[‘price’][df[‘A’]] but it doesn’t work. input expected result table Answer …

Separate columns of a DataFrame by days of the week

Let it be the following Python Panda Dataframe (the original could include dates for several months): Hours 2022-06-06 2022-06-07 2022-06-08 2022-06-09 2022-06-10 2022-06-11 2022-06-12 2022-06-13 2022-06-14 2022-06-15 2022-06-16 2022-06-17 2022-06-18 2022-06-19 00:00 3 0 0 3 23 43 1 2 3 3 7 3 1 0 05:00 5 4 0 …

How add value in second row into first row?

I would like to add a new columns from a values of ‘Pr’ in second rows for each value same id and date. Input a: ID Date order Date restock Pr Infos 778005 2022-04-07 11:34:46.0 NaN 87.0;113001.0;00 a 778005 2022-04-07 11:34:46.0 NaN 87.0;113159.0;FC at 7001 2021-12-10 13:50:46.0 2021-12-13 00:00:…