Jul-05-2021, 08:14 AM
(This post was last modified: Jul-05-2021, 08:14 AM by shantanu97.)
Data looks like when I open this csv in Notepad.
I want to replace the "magneticfields\nD" with nothing in the Magnetic Declination column.
data['Magnetic Declination'] = data['Magnetic Declination'].apply(lambda x: x.replace(r"magneticFields\nD ", ""))
- Year Latitude Longitude Magnetic Declination SourceFile
1985 88 75 " magneticFields
D 41.971 deg" https://api.geomagnetism.ga.gov.au/agrf
1986 88 75 " magneticFields
D 42.179 deg" https://api.geomagnetism.ga.gov.au/agrf
1987 88 75 " magneticFields
D 42.390 deg" https://api.geomagnetism.ga.gov.au/agrf
I want to replace the "magneticfields\nD" with nothing in the Magnetic Declination column.
data['Magnetic Declination'] = data['Magnetic Declination'].apply(lambda x: x.replace(r"magneticFields\nD ", ""))
import pandas as pd import re data = pd.read_csv("magnetic_declination_australia_1.csv") data.head() data['Magnetic Declination'] = data['Magnetic Declination'].apply(lambda x: x.replace(r"magneticFields\nD ", "")) data.head()can anyone one help how to fixed this? csv file and code are attached.
Attached Files
