Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Add new column of dataframe

Other['Extracurr'] = count
Comment

add new column to pandas dataframe

# Import pandas package
import pandas as pd
 
# Define a dictionary containing Students data
data = {'Name': ['Jai', 'Princi', 'Gaurav', 'Anuj'],
        'Height': [5.1, 6.2, 5.1, 5.2],
        'Qualification': ['Msc', 'MA', 'Msc', 'Msc']}
 
# Convert the dictionary into DataFrame
df = pd.DataFrame(data)
 
# Declare a list that is to be converted into a column
address = ['Delhi', 'Bangalore', 'Chennai', 'Patna']
 
# Using 'Address' as the column name
# and equating it to the list
df['Address'] = address
 
# Observe the result
df
Comment

PREVIOUS NEXT
Code Example
Python :: how to make a pairs plot with pandas 
Python :: to_csv drop index 
Python :: sort dictionary python 
Python :: making a python code without python 
Python :: how to get more than one word in a list in python 
Python :: typingclub hack python 
Python :: wonsan 
Python :: import math print(math.log(1024,2)) 
Python :: per gjera te shumta. Python 
Python :: python list comprehension index, value 
Python :: python to exe 
Python :: add footer embed discordpy 
Python :: taking hour information from time in pandas 
Python :: python seaborn heatmap decrease annot size 
Python :: change pandas column value based on condition 
Python :: how to show process bar in terminal python 
Python :: payizone 
Python :: df invert sort index 
Python :: python record screen 
Python :: how to save to file in python 
Python :: urllib python 
Python :: python check if string starting with substring from list ltrim python 
Python :: how to convert a dense matrix into sparse matrix in python 
Python :: bring tkinter window to front 
Python :: python create tuple from input 
Python :: scrape with beautiful soup 
Python :: django admin order by 
Python :: max int value in python 
Python :: how to get the index of a value in pandas dataframe 
Python :: pyspark add string to columns name 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =