CSE 6040 - 7.1 - Merging data frames: join operations - Code Flashcards
Write the code to display the following table as Table A.
See Pic
Write the code to display Table B.
See Pic
Write the code to display an inner-merge on Tables and and B on keys “country” and “year”.
See pic
Given the following tables. Perform a left and right merge on the following tables D and E.
See Pic
What’s the command to copy a dataframe named ‘C’ to a new dataframe ‘G’?
G = C.copy() # If you do not use copy function the original data frame is modified
use the apply function on the dataframe ‘s’ to this function called fun
import pandas as pd
reading csv
s = pd.read_csv(“stock.csv”, squeeze = True)
defining function to check price
def fun(num):
if num<200:
return “Low”
elif num>= 200 and num<400:
return “Normal”
else:
return “High”