Question: I am trying to learn how to manipulate CSV files in python 3.x and I'm using Anaconda's Spyder IDE to do it When I execute the code I get " No such file or directory exists".

I have already tried uninstalling and reinstalling anaconda to make sure I have it added to my PATH. I have also tried moving the CSV around to other files to see if it can locate it but nothing.

```
import csv
with open('bar.csv', newline='') as csvfile:
 reader = csv.reader(csvfile, delimiter=' ', quotechar='|')   
 for row in reader:
    print(', '.join(row))

```

FileNotFoundError: [Errno 2] No such file or directory: 'bar.csv'

Answer: 
Use [`numpy.where`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html):

```
df['Hired'] = pd.np.where(df.Hired == 'Y', 1, 0)

```

Or [`pandas.Series.map`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.map.html):

```
df['Hired'] = df.Hired.map({'Y': 1, 'N', 0})

```

Which is less efficient, but can handle more than two cases.

Note than these will be faster than`apply` on 1000+ rows.
I think you're looking for the `apply` method, [pandas.Series.apply](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.apply.html#pandas.Series.apply), which can be used to run a function for each value in the Series.

In your case, using an anonymous function...

```
df['Hired'] = df['Hired'].apply(lambda x: 1 if x == 'Y' else 0)

```

... where `x` is each value in the Series.