> Now the problem here is that multiplication of a column with a scaler just multiplies the value in that column to appear multiple times for instance df[L1] = df[L1]*50 will make values of L1 repeat 50 times in the entire column but what I want is to multiply each value in that column to be multiplied by 50. here
Tag: dataframe
is there a way to delete or replace any row on my data that it’s type is ‘datetime.datetime’
I have 1200000 rows x 96 columns dataframe, they are numbers, except for a few of them whose types are date and time. The Question is: I’d like to remove any row whose type is datetime.datetime and convert the rest to float if they are number but their type is string Answer This should get you the results you requested
Adding counts from one dataframe to another dataframe on corresponding row
I would like to count the number of record in dataframe2 and add the count to the corresponding rows in dataframe1. The first one (df1) Road RoadNo Count A 1 0 A 2 0 B 1 0 B 2 0 The second one (df2) Road RoadNo A 1 A 1 A 1 A 2 A 2 B 1 The expected
Replace zero values on all columns if sum of that columns is greater than 1?
I have CSV files like following I want to replace Result1, Result2, and Result3 columns by all zero if the sum of their column values is greater than 1. I tried this script When I do this operation Result3 column is dropped since it has all zero values. How do I do this operation only on the columns which satisfy
Adding a full stop to text when missing
How to add a full stop to a text please? I am not able to get the desired combined text. Answer You can use where and cat: Result: (this also works for the case when text1 is given and text2 is NaN)
Python if statement not working correctly and no idea why
In my code I iterate through dataframes of each year to calculate the number of wins (increase between numbers) and losses (decrease between numbers), and the ratio of wins to losses. The loop I run correctly displays the right number of wins and losses in the dataframe they are eventually pushed to. However, when calculating the win/loss ratio, the if
Problems with DataFrame indexing with pandas
Using pandas, I have to modify a DataFrame so that it only has the indexes that are also present in a vector, which was acquired by performing operations in one of the df’s columns. Here’s the specific line of code used for that (please do not mind me picking the name ‘dataset’ instead of ‘dataframe’ or ‘df’): it worked, and
Update columns with duplicate values from the DataFrame in Pandas
I have a data set which has values for different columns as different entries with first name to identify the respective columns. For instance James’s gender is in first row and James’s age is in 5th row. DataFrame df1= Index First Name Age Gender Weight in lb Height in cm 0 James Male 1 John 175 2 Patricia 23 5
Reshaping long format dataframe to wide format according to the number of elements in columns [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 months ago. Improve this question I have the following pandas dataframe X in long format: And I would like to change to the following wide format according the number of
Python DataFrame String replace accidently Returing NaN
I encounter a weird problem in Python Pandas, while I read a excel and replace a character “k”, the result gives me NaN for the rows without “K”. see below image It should return 173 on row #4,instead of NaN, but if I create a brand new excel, and type the same number. it will work. or if i use