I came up with the idea of analyzing data in Python 2.7.6 with pycharm. Unable to read the csv file to be analyzed, After investigating various things for several hours, I solved it by the following method.
Well, it seems that pandas is good for analyzing data, So I installed pandas on pycharm. So, it seems that you can read csv by using read_csv of pandas, so I immediately tried the following.
Csv reading using pandas
import pandas as pd
df = pd.csv_read("/File path to directory/test.csv")
print df
However, as a result, it cannot be read and the following error message is displayed. .. ..
csv read result in pandas
IOError: File test.csv does not exist
After a lot of research to solve this problem, Apparently the csv_read method is directly from the file path I can't call the file, and even where the file I want to call is I found that I had to specify the path and change the working directory.
I had to use os.chdir to change the working directory.
Specify a working directory and read csv using pandas
import pandas as pd
import os
#Specify the path to the working directory where the data is stored
os.chdir("/File path to directory")
#read csv
df= pd.read_csv("test.csv")
print df
With the above method, I was able to read csv safely!
Recommended Posts