Question: I'm just starting out learning Python/Spyder. I have completed a few classes in R for data science.

Below is failing with the error: IOError: File APPL.csv does not exist 

However, my script and .csv file are in the same folder. Any thoughts on what I'm doing wrong? Thanks

```
    import pandas as pd

     def test_run():
         df = pd.read_csv("APPL.csv")
         print df

     if __name__ == "__main__":
          test_run()

```

Answer: 
I implemented my own version of k-means on top of spark which uses standard TF-IDF vector representation and (-ve) cosine similarity as the distance metric [code snippet for reference](https://gist.github.com/rajanim/e01d1af591d697202c75ee0a785fa94f). The results from this k-means look right, not as skewed as spark k-means. [figure 1 and 2](https://i.stack.imgur.com/CkcIZ.png)
Additionally, I experimented by plugging in Euclidean distance as a similarity metric (into my own version of k-mean) and results continue to look right, not at all as skewed as spark k-means. Results indicate that its not issue with distance measure but some other case with spark's k-means implementation(scala mllib)
The KMeans algorithm is based on Euclidean distance, and can not directly use cosine distance. [Here](https://stats.stackexchange.com/questions/81481/why-does-k-means-clustering-algorithm-use-only-euclidean-distance-metric) is a good explanation of this fact:

> 
> K-Means is implicitly based on pairwise Euclidean distances b/w data points, because the sum of squared deviations from centroid is equal to the sum of pairwise squared Euclidean distances divided by the number of points.
> 
> 
> 

If you wish to use cosine distance (or any other metric), [KMedoids](https://en.wikipedia.org/wiki/K-medoids) might be a good option. It is similar to KMeans, but uses the median, instead of the mean, in it's update step. This allows the use of arbitrary distance metrics.