Question: I have downloaded some data, so I wanted to change some values into boolean type:

```py
for dataset in loan_df:
    dataset['Gender'] = dataset['Gender'].replace({'male' : 1 , 'female' : 0} , inplace = True)

```

but it is giving me this error :

```
TypeError: string indices must be integers

```

I also tried this code :

```py
for dataset in loan_df:
    dataset['Gender'] = dataset['Gender'].map({'male' : 1 , 'female' : 0}).astype(int)

```

But it is still giving the same error. Do you know how to resolve this error?

Answer: 
Presuming the bold **A** in each schema means it is a key; and presuming the Foreign Key constraint holds -- that is, the `A` value for every row in `R` does correspond to an `A` value in `S`:

* Every row in `R` naturally joins to a row in `S` on `A`.
* There might be rows in `S` that don't join to `R` (because there's no Foreign Key constraint to enforce that).
* So the cardinality of the joined relations is the cardinality of `R`, answer 1.

Is there are real-life use for a schema like this? Consider `S` is Customer Name in `C`, keyed by Customer number in `A`. `R` holds date of birth in `B`, also keyed by Customer number in `A`. Every Customer must have a name; it's true every Customer (person) must have a d.o.b., but we don't need to record that unless/until they purchase age-restricted items.
There is absolutely not enough information to answer this question. The "natural" join can return any almost any value between 0 and R\*S. The following are examples. 

This example returns 12:

```
create table s1 (id int primary key);
create table r1 (s1_id int references s1(id));

insert into s1 (id) values (1), (2), (3);

insert into r1 (s1_id) values (1), (2), (2), (3);

```

This example returns 0:

```
create table s2 (id int primary key, x int default 2);
create table r2 (s2_id int references s2(id), x int default 1);

insert into s2 (id) values (1), (2), (3);

insert into r2 (s2_id) values (1), (2), (2), (3);

```

This examples returns 4:

```
create table s3 (id int primary key, y int default 2);
create table r3 (id int references s3(id), x int default 1);

insert into s3 (id) values (1), (2), (3);

insert into r3 (id) values (1), (2), (2), (3);

```

In all of these, `r` has a foreign key relationship to `s`. And a "natural" join is being used. [Here](https://dbfiddle.uk/?rdbms=postgres_12&fiddle=4a7730398a73ad7651e12a9cc901a555) is a db<>fiddle.

Even if you assume that the "A"s are the primary keys AND that there are no other columns, the number of rows still varies:

```
-- returns 4
create table s5 (id int primary key);
create table r5 (id int references s4(id));

insert into s5 (id) values (1), (2), (3);    
insert into r5 (id) values (1), (1), (2), (2);

```

Versus:

```
-- returns 0
create table s4 (id int primary key);
create table r4 (id int references s4(id));

insert into s4 (id) values (1), (2), (3);

insert into r4 (id) values (NULL), (NULL), (NULL), (NULL);

```