Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas split column into multiple columns by delimiter

df[['A', 'B']] = df['AB'].str.split(' ', 1, expand=True)
Comment

split a column into multiple columns

df[['A', 'B']] = df['AB'].str.split(' ', 1, expand=True)
df['A'], df['B'] = df['AB'].str.split('-', 1).str
Comment

pandas split column into multiple columns

df.Name.str.split(expand=True,)
          0  1
0   Steve   Smith
1   Joe Nadal
2   Roger   Federer
Comment

Split Column with delimiter into multiple columns

DECLARE @tt TABLE(i INT IDENTITY,x VARCHAR(8000));
INSERT INTO @tt(x)VALUES('-9;-9;-1;-9;-9;-9;-9;-9;-1;-9;-9;-9;-9;-9;-9;-9;-9;-9;-1;-9;-9;-9;-9;-9;-9;-9;-9;-9;-1;-9;-1;-9;-9;-9;-1;-9;-9;-9;-9;-9;-9;-1;-1;-1;-1;-9;-1;-1;-9;-9;-9;-9;-1;-9;-1;-9;-9;-9;-1;-9;-1;-9;-1;-9;-9;-9;-9;-1;-9;-9;-1;-1;-9;-1;-1;0000;FFF8;-9;-9;-9;-1;-9;-1;-9;FFF6;-9;-1;-9;-1;-9;-1;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9;-9');

SELECT
    i,
    val1=n.v.value('/e[1]','VARCHAR(16)'),
    val2=n.v.value('/e[2]','VARCHAR(16)'),
    val3=n.v.value('/e[3]','VARCHAR(16)'),
    -- ... repeat for val4 .. val114
    val115=n.v.value('/e[115]','VARCHAR(16)')
FROM
    @tt
    CROSS APPLY (
        SELECT 
            CAST('<e>'+REPLACE(x,';','</e><e>')+'</e>' AS XML) AS itm
    ) AS i
    CROSS APPLY i.itm.nodes('/') AS n(v);
Comment

PREVIOUS NEXT
Code Example
Python :: gcp functions save BQ 
Python :: notebook python static website generator 
Python :: how to update pip python 
Shell :: error: cannot install "code": classic confinement requires snaps under /snap or symlink from /snap 
Shell :: chrome inspect devices 
Shell :: pip install django storages 
Shell :: restart apache ubuntu 
Shell :: git store credential 
Shell :: how to upgrade pip 
Shell :: how to uninstall react native cli globally 
Shell :: how to remove spacevim 
Shell :: Remove composer for ubuntu 
Shell :: uninstall wps office 
Shell :: how to kill a process on a port? 
Shell :: remove docker container 
Shell :: reset a branch to master 
Shell :: Install redis on macbook pro 
Shell :: copy ssh key ubuntu 
Shell :: reinit gitignore 
Shell :: linux sort folders by size 
Shell :: yarn install 
Shell :: Install xlrd = 1.0.0 for Excel support Use pip or conda to install xlrd 
Shell :: how to uninstall jdk java 
Shell :: shutdown pc in 10 min run command 
Shell :: install pandas conda 
Shell :: homebrew cocoapods 
Shell :: how to know screen resolution linux 
Shell :: Error loading MySQLdb module. 
Shell :: how to check if mysql is installed ubuntu 
Shell :: docker remove all untagged images 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =