CSE 6040 - 7.1 - Merging data frames: join operations - Code Flashcards

1
Q

Write the code to display the following table as Table A.

A

See Pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Write the code to display Table B.

A

See Pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Write the code to display an inner-merge on Tables and and B on keys “country” and “year”.

A

See pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Given the following tables. Perform a left and right merge on the following tables D and E.

A

See Pic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What’s the command to copy a dataframe named ‘C’ to a new dataframe ‘G’?

A

G = C.copy() # If you do not use copy function the original data frame is modified

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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”

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly