Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

split column and rename them

# importing pandas module 
import pandas as pd
   
# reading csv file from url 
data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")
  
# dropping null value columns to avoid errors
data.dropna(inplace = True)
  
# new data frame with split value columns
new = data["Name"].str.split(" ", n = 1, expand = True)
  
# making separate first name column from new data frame
data["First Name"]= new[0]
  
# making separate last name column from new data frame
data["Last Name"]= new[1]
  
# Dropping old Name columns
data.drop(columns =["Name"], inplace = True)
  
# df display
data
Comment

PREVIOUS NEXT
Code Example
Python :: python heighest int Value 
Python :: how to get a list of files in a folder in python with pathlib 
Python :: python manual elif 
Python :: argsort in descending order numpy 
Python :: legend ax matplotlib 
Python :: python change version 
Python :: find rules of decision tree python 
Python :: Python Difference between two timedelta objects 
Python :: been deprecated, please pass in a Service object 
Python :: seaborn bar plot sort for weekday 
Python :: python os path safe string 
Python :: scikit learn decision tree 
Python :: accessing values in dictionary python 
Python :: munshi premchand 
Python :: message to dict protobuf 
Python :: crawling emails with python 
Python :: HOW TO CREATE A DATETIME LIST QUICK 
Python :: flask sqlalchemy case insensitive like 
Python :: unable to import flask pylint 
Python :: instance variable python 
Python :: python indian currency formatter 
Python :: python button graphics.py 
Python :: print 
Python :: Print characters from a string that are present at an even index number 
Python :: declare array python 
Python :: append numeric number in and auto increment in using pandas 
Python :: most occurring element in array python 
Python :: from future import division 
Python :: pd calculations between columns 
Python :: best time to buy and sell stock python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =