dataframe

How to drop_duplicates but remain a specified value in pandas dataframe?

How to drop_duplicates but remain a specified value in pandas dataframe? Question: enter image description here date price_bl price_ss price_bs price_sl 0 2022-03-09 03:00:00 41198.5 NaN NaN NaN 0 2022-03-10 01:00:00 NaN NaN NaN 40931.0 0 2022-03-10 01:00:00 NaN NaN 40931.0 NaN 1 2022-03-16 02:00:00 40867.8 NaN NaN NaN 0 2022-03-16 02:00:00 NaN 40867.8 NaN …

Total answers: 1

polars – Fill null over Groups

polars – Fill null over Groups Question: I am trying to fill null timestamps over groups, my dataframe looks like this start stop group 0 2021-12-08 06:40:53.734941+01:00 2022-05-16 10:16:18.717146+02:00 1 1 2021-12-08 06:40:55.191598+01:00 null 1 2 2021-12-08 10:39:12.421402+01:00 2022-05-16 10:16:19.816922+02:00 2 3 2021-12-08 10:39:12.634873+01:00 2022-05-16 10:16:19.817304+02:00 1 4 2021-12-08 10:49:47.392815+01:00 2022-05-16 10:16:20.178050+02:00 5 The stop …

Total answers: 1

Check if comma separated values in a dataframe contains values from another dataframe in python and add corresponding value

Check if comma separated values in a dataframe contains values from another dataframe in python and add corresponding value Question: I have 2 dataframes that looks like this (my origianl dataset is huge): df1: gene_callers_id 0 4717766,4743899,11597717,12116240 1 4717766,4743899,12116240,7719716,4022000 2 4717766,4743899,12116240,7248697,7719716 df2: gene_callers_id sample_1 sample_2 0 4743899 0.345000 0.176000 1 4717766 0.000000 2.500000 2 4743898 …

Total answers: 1

Combine two rows in data frame in python

Combine two rows in data frame in python Question: I have a data frame which has two columns and one column has a duplicate values .I want to combine the rows into one . But I dont want to run any aggregation function . My data frame is My data frame df CP CL 0 …

Total answers: 1

Pandas new column from counts of column contents

Pandas new column from counts of column contents Question: A simple data frame that I want to add a column, to tell how many Teams that the Project has, according to a name dictionary. The way I came up with seems working ok but doesn’t look very smart. What is a better way to do …

Total answers: 1

How do I select a subset of a DataFrame based on a condition on a column

How do I select a subset of a DataFrame based on a condition on a column Question: Similar to How do I select a subset of a DataFrame based on one level of a MultiIndex, let df = pd.DataFrame({"v":[x*x for x in range(12)]}, index=pd.MultiIndex.from_product([["a","b","c"],[1,2,3,4]])) and suppose I want to select only rows with the v …

Total answers: 1

How do I select a subset of a DataFrame based on one level of a MultiIndex

How do I select a subset of a DataFrame based on one level of a MultiIndex Question: Let df = pd.DataFrame({"v":range(12)}, index=pd.MultiIndex.from_product([["a","b","c"],[1,2,3,4]])) and suppose I want to select only rows with the first level being a or c: v a 1 0 2 1 3 2 4 3 c 1 8 2 9 3 10 …

Total answers: 1