Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas dataframe add two columns int and string

df = df['Day'].map(str) + '-' + df['Month'].map(str) + '-' + df['Year'].map(str)
Comment

sum two columns pandas

sum_column = df["col1"] + df["col2"]
Comment

add values of two columns pandas

df['sum'] = df['a'] + df['b']  # sum is a new column
Comment

pandas dataframe add two columns int and string

df1 = df['1st Column Name'].map(str) + df['2nd Column Name'].map(str) + ...
Comment

add values from 2 columns to one pandas

df['Fruit Total']= df.iloc[:, -4:-1].sum(axis=1)
print (df)
   Apples  Bananas  Grapes  Kiwis  Fruit Total
0     2.0      3.0     NaN    1.0          5.0
1     1.0      3.0     7.0    NaN         11.0
2     NaN      NaN     2.0    3.0          2.0
Comment

insert multiple column pandas

df['column_new_1'], df['column_new_2'], df['column_new_3'] = [np.nan, 'dogs', 3]
Comment

PREVIOUS NEXT
Code Example
Python :: loop through files in a directory python 
Python :: atoi in python code 
Python :: logger 
Python :: python environment 
Python :: Counter() Function 
Python :: Sendgrid dynamic templating 
Python :: change part of a text file python 
Python :: how to check if digit in int python 
Python :: delete file in django terminal 
Python :: python math exp 
Python :: python dict delete key 
Python :: upgrade python version windows 
Python :: issubclass python example 
Python :: _ in python 
Python :: how to convert string to int in python 
Python :: NumPy invert Syntax 
Python :: python how to switch between true and false 
Python :: run ipython inside pipenv 
Python :: how to separate numeric and categorical variables in python 
Python :: kwargs in python 
Python :: print list of list line by line python 
Python :: drop pandas 
Python :: python webview 
Python :: django-multivaluedictkeyerror-error 
Python :: python size of set 
Python :: how to write something in python 
Python :: gaussian 
Python :: python transpose 
Python :: docker hub python 
Python :: string template python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =