Feb-17-2018, 02:26 PM
Hi, I have a column in a dataframe/table called "LSOA Name". 1st issue is the field has a name in it. Referencing it as "df1['LSOA name']" seems to work ok.
What I am really trying to do is split the column up as it has a code at the end I don't want. In something like SQL i would code as select substr(['LSOA name'],1,len(['LSOA name'])-4) as LSOA_Area from...
Can I do the same thing in Python?
I have tried the following - df1['LSOA name'].str.slice(0, len(df1['LSOA name'])-4)
This returns the full string, what I need is the value from digit 1 to the length of the value less 4.
any help appreciated.
Andrew
What I am really trying to do is split the column up as it has a code at the end I don't want. In something like SQL i would code as select substr(['LSOA name'],1,len(['LSOA name'])-4) as LSOA_Area from...
Can I do the same thing in Python?
I have tried the following - df1['LSOA name'].str.slice(0, len(df1['LSOA name'])-4)
This returns the full string, what I need is the value from digit 1 to the length of the value less 4.
any help appreciated.
Andrew