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 coumn of df into multiple dynamic columns

d = [pd.DataFrame(df[col].tolist()).add_prefix(col) for col in df.columns]
df = pd.concat(d, axis=1)

   id0  id1   id2  value0  value1  value2
0   10   10   NaN   apple  orange    None
1   15   67   NaN  banana  orange    None
2   12   34  45.0   apple  banana  orange
Comment

pandas split cell into multiple columns

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

split rows into multiple columns in pandas

df = pd.DataFrame(df.Raw_info.values.reshape(-1, 3), 
                   columns=['Function_name', 'prop1', 'prop2'])

print(df) 
  Function_name            prop1            prop2
0    Function_1  internal_prop_1  external_prop_1
1    Function_2  internal_prop_2  external_prop_2
2    Function_3  internal_prop_3  external_prop_3
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 :: edit path variable using python 
Python :: snapchat api in python 
Python :: argparse flag without value 
Python :: python get object name 
Python :: python split string with a seperator 
Python :: python for data analysis 
Python :: python float range 
Python :: remove trailing zeros python 
Python :: fillna spark dataframe 
Python :: exit a pygame program 
Python :: empty array python 
Python :: beautifulsoup remove empty tags 
Python :: bubble sort in python 
Python :: python if boolean logic 
Python :: discord.py events 
Python :: create an empty array numpy 
Python :: pandas compare two columns of different dataframe 
Python :: flask abort 
Python :: tuple in python 3 
Python :: add list python 
Python :: concatenate list in python 
Python :: python install graphviz and 
Python :: sequence with numbers in python 
Python :: Python recursively find files with specific ext 
Python :: how many numbers greater than 100 using pytho 
Python :: get python to run cli commands 
Python :: python rock paper scissors game 
Python :: remove a first array of item in python 
Python :: python dataframe contains value 
Python :: boolien in python 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =