multiple-columns

Process columns based on column names in another column

Process columns based on column names in another column Question: I like to select cells for processing by choosing column names contained in a different column. For clarity, input and output are given below. Column ‘a’ contains the column names for setting the value to None for each row. I tried to code as below …

Total answers: 1

Pandas Dataframe increased or decreased in a certain amount of time

Pandas Dataframe increased or decreased in a certain amount of time Question: I have a DataFrame with the following structure: # Import pandas library import pandas as pd # initialize list of lists data = [[‘R.04T’, 1, 2013, 23456, 22, 1 ], [‘R.04T’, 15, 2014, 23456, 22, 1], [‘F.04T’, 9, 2010, 75920, 00, 3], [‘F.04T’, …

Total answers: 1

Pandas Multiply Columns Using Conditional Column Names

Pandas Multiply Columns Using Conditional Column Names Question: I am trying to simply multiply columns in a single DF based on the column names starting with a string. If a column contains that "string" value, then the values in those columns are multiplied by a value in a different column (column = Avg_Adj_Prod). Here is …

Total answers: 1

Assign new column in DataFrame based on if value is in a certain value range

Assign new column in DataFrame based on if value is in a certain value range Question: I have two DataFrames as follows: df_discount = pd.DataFrame(data={‘Graduation’ : np.arange(0,1000,100), ‘Discount %’ : np.arange(0,50,5)}) df_values = pd.DataFrame(data={‘Sum’ : [20,801,972,1061,1251]}) Now my goal is to get a new column df_values[‘New Sum’] for my df_values that applies the corresponding discount …

Total answers: 3

Clean column in data frame

Clean column in data frame Question: I’m trying to clean one column which contains the ID number which is starting from S and 7 numbers, e.g.: ‘S1234567’ and save only this number into new column. I started with this column named Remarks, this is an example of the data inside: Remarks 0 S0252508 Shippment UK …

Total answers: 2

Performing calculations in python using excel values

Performing calculations in python using excel values Question: I’m trying to do some calculations in python using an excel with several rows and using 3 columns. I’m using the columns ‘Band’ and ‘Antenna_Heigh’ and I would like to save these values in the column ‘Colors’. My code looks like this but I have an error …

Total answers: 2

Is there a way to remove header and split columns with pandas read_csv?

Is there a way to remove header and split columns with pandas read_csv? Question: [Edited: working code at the end] I have a CSV file with many rows, but only one column. I want to separate the rows’ values into columns. I have tried import pandas as pd df = pd.read_csv("TEST1.csv") final = [v.split(";") for …

Total answers: 1