Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to apply 1nf dataframe in python

01
02
03
04
05
06
07
08
09
10
11
12
import pandas as pd
import numpy as np
 
df = pd.DataFrame({'Name': ['David', 'Glenn', 'Steve'], 'Subjects': [
                  ['English', 'Math'], ['Math'], ['Science', 'English']]})
 
lens = list(map(len, df['Subjects'].values))
 
res = pd.DataFrame({'Name': np.repeat(
    df['Name'], lens), 'Subject': np.concatenate(df['Subjects'].values)})
 
print(res)
Comment

PREVIOUS NEXT
Code Example
Python :: create model object from dictionary 
Python :: dictionary changed size during iteration after pop function 
Python :: semaphore example in python 
Python :: python extract words from string with format 
Python :: seconds since epoc python 
Python :: tuple with only one element in Python 
Python :: the command 
Python :: slug in redirect django 
Python :: networkx select edge 
Python :: first n lis tpython 
Python :: pandas drop unnamed columns grebber 
Python :: k and M to int in pandas 
Python :: pytorch_starting 
Python :: arm str example 
Python :: comprehensions 
Python :: initialize boolean list of size python 
Python :: pivot_table indexing 
Python :: numpy np sign change in df pandas zero crossing 
Python :: reading a cell from another cell in colab 
Python :: torch.unsqueeze 
Python :: count each value in lsitp ython 
Python :: py if else if 
Python :: how to print a text 
Python :: split() method, sep=i, n=veces aplicado 
Python :: prime palindrome number in python 
Python :: how to launch a application using python 
Python :: unban member using ID discord.py 
Python :: inline keyboard telegram bot python 
Python :: how to remove a specific element from an array in python 
Python :: python oops 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =