I have this data frame (columns are strings): I need to get ‘ORF’ values for rows with ‘ORFDesc’ that contains a word with “hydro” but only with 13 characters. I explain, word length must be 13 characters, not the whole description. I’m using In order to match the row…
Tag: pandas
Is there any possibility to create a new column based on the keywords list
Is there any possibility to create a new column based on the keywords list? I have data like this: I would like to create a new column if the keyword exists in the Type column and if 2 keywords exist then the value should both keyword with a comma. I am having a problem because I have to check also
Conditionally replace values in list of arrays in a pandas dataframe
I would like to conditionally replace values in a column that contains a series of arrays. Example dataset below: (my real dataset contains many more columns and rows) For example, if the condition is A and the row contains ‘1 pumpkin’, then I would like to replace the value with XXX. But if the c…
python – find duplicates in a column, replace values in another column for that duplicate
I have a dataframe that consists of of video game titles on various platforms. it contains, among other values the name, critic’s average score and user’s average score. Many of them are missing scores for the user, critic and/or ESRB rating. What i’d like to do is replace the missing rating…
Loop through a few commands using a function
I have a loop where I constantly got an error message. I want to loop them through a function. So far I have: How can I number the df and let the df go through 1, 2, 3, 4 (like df1, df2 df3) Answer col is a variable. ‘col’ is a string. Having df[‘col’] doesn’t refer to the variab…
Color in cell containing a string Pandas
i am trying to change the background color in my dataframe if a column contains a certain string however i cant seem to get it to work. I have the following code so far: but it doesn’t seem to do anything to the cells. Is there anything i am doing wrong? Code: Answer You can use custom function for crea…
How to concatenate dataframes without overwriting column values
I am trying to create a list of DataFrames in a for loop, and then concatenate them outside of the for loop and write to excel. I have gotten the code to be close, but for some reason the column created inside the for loop ends up being the final value rather each individual value as it loops through. I
Printing pandas df without column name
I’ve been trying to open a .csv, read it in pandas, and print it without the column name. The code I have Outputs something like this How would I make it so values equal only 12343 and not Value 12343 Answer Try:
Pandas Cumcount() over multiple columns
I have a dataframe that looks like this: What I want to do is to add two columns, one for set number and one for rep number. Set number should increase by 1 for each weight change exercise & session is the same, else reset to 0. Rep number should increase by 1 for each velocity change if exercise, session
Minimum value for each row in pandas dataframe
im trying to compute the minimum for each row in a pandas dataframe. I would like to add a column that calculates the minimum values and ignores “NaN” and “WD” For example should give me a new column like I tried df.where(df > 0).min(axis=1) and df.where(df != “NaN”).min…