Python Forum
Want to remove the text from a particular column in excel
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want to remove the text from a particular column in excel
#3
Hi shantanu97,

The following, is an alternative simpler method than Larz60+'s, it worked for me :-

import pandas as pd
import re

data = pd.read_csv("magnetic_declination_australia_1.csv") 
#print(data.head())
#data['Magnetic Declination'] = data['Magnetic Declination'].apply(lambda x: x.replace(r"magneticFields\nD ", ""))
data['Magnetic Declination'] = data['Magnetic Declination'].str.replace('magneticFields\nD', '')
#print(data.head())
data
Best Regards

Eddie Winch Smile
Larz60+ likes this post
Reply


Messages In This Thread
RE: Want to remove the text from a particular column in excel - by eddywinch82 - Jul-05-2021, 05:42 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,136 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  How to remove footer from PDF when extracting to text jh67 3 5,115 Dec-13-2022, 06:52 AM
Last Post: DPaul
  How to remove patterns of characters from text aaander 4 1,124 Nov-19-2022, 03:34 PM
Last Post: snippsat
  Two text files, want to add a column value zxcv101 8 1,947 Jun-20-2022, 03:06 PM
Last Post: deanhystad
  How to format Excel column with comma? dee 0 1,377 Jun-13-2022, 10:11 PM
Last Post: dee
  Appending Excel column value as CSV file name sh1704 0 1,307 Feb-06-2022, 10:32 PM
Last Post: sh1704
  How to remove a column or two columns in a correlation heatmap? lulu43366 3 5,244 Sep-30-2021, 03:47 PM
Last Post: lulu43366
  beginner text formatting single line to column jafrost 4 3,235 Apr-28-2021, 07:03 PM
Last Post: jafrost
  More elegant way to remove time from text lines. Pedroski55 6 3,959 Apr-25-2021, 03:18 PM
Last Post: perfringo
  Copy column from one existing excel file to another file mkujawsk 0 5,652 Apr-14-2021, 06:33 PM
Last Post: mkujawsk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020