Skip to content

Instantly share code, notes, and snippets.

@lauramsfernandes
Last active May 30, 2021 15:17
Show Gist options
  • Save lauramsfernandes/fa89721224efe03fcfb71272dd36a768 to your computer and use it in GitHub Desktop.
Save lauramsfernandes/fa89721224efe03fcfb71272dd36a768 to your computer and use it in GitHub Desktop.
DataFrame Categorial Variables
import pandas as pd
index = ['Ana', 'Ian', 'Eva', 'Dan', 'Kim']
columns = ['Color', 'Type', 'Length']
ana = ['Brown', 'Straight', 'Short']
ian = ['Black', 'Wavy', 'Short']
eva = ['Red', 'Curly', 'Long']
dan = ['Blonde', 'Straight', 'Long']
kim = ['Brown', 'Curly', 'Medium']
data = [ana, ian, eva, dan, kim]
df = pd.DataFrame(data, index=index, columns=columns)
df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment