Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The result will be like below

Result 

{'Seoul', 'Incheon'}

{'Seoul', 'Incheon'}


Find different elements from two arrays based on "symmetric_difference" method

...

The result will be like below

Result 

{'Jake', 'Eric', 'Jill'}

{'Eric', 'Jake', 'Jill'}


Find different elements from two arrays based on "difference" method

...

The result will be like below

Result 

{'Jake', 'Eric'}

{'Jill'}


Find different elements from two arrays based on "union" method

...

The result will be like below

Result 

{'John', 'Eric', 'Jake', 'Jill'}


Print out a set containing all the participants from event A which did not attend event B

Code Block
a = ["Jake", "John", "Eric"]
b = ["John", "Jill"]

print(set(a).difference(set(b)))


Pandas DataFrame / CSV / Join / Merge

Create a Pandas DataFrame based on array

...

Code Block
# Import cars data
import pandas as pd
cars = pd.read_csv('cars.csv', index_col = 0)

# Print out first 4 observations
print(cars[0:4])

# Print out fifth, sixth, and seventh observation
print(cars[4:6])


Data access by loc and iloc in Pandas DaraFrame - Select colums by index or name

loc is label-based, and iloc is integer index based

...