Cara Menerapkan 1NF DataFrame di 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)
Encouraging Elephant