31 July 2020
Code
# Import library
import pandas as pd
# Create 2D array
animals = np.array([['cat', 'meow'],
['cat', 'meow'],
['dog', 'bark'],
['dog', 'bark'],
['cat', 'meow']])
# Create DataFrame
df = pd.DataFrame(
animals,
columns=['animals', 'sound']
)
# Output
print(df)
Output
animals sound
0 cat meow
1 cat meow
2 dog bark
3 dog bark
4 cat meow
Any errors in code above?
Please send a message.