Final df to csv - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Final df to csv (/thread-17666.html) |
Final df to csv - HierroDuc1 - Apr-19-2019 I'm having trouble saving the data-frame as a CSV. >>> print(len(df)) 221 >>> final_df = df.sort_values('popularity', ascending=False).drop_duplicates('name').sort_index() >>> print(len(final_df)) 116 >>> >>> final_df.to_csv("{a file location to store your csv}") >>> final_df.to_csv("Desktop") >>> final_df.to_csv("/Users/Pablo/Desktop/SP") Traceback (most recent call last): File "<pyshell#136>", line 1, in <module> final_df.to_csv("/Users/Pablo/Desktop/SP") File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/core/generic.py", line 3020, in to_csv formatter.save() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/formats/csvs.py", line 157, in save compression=self.compression) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/io/common.py", line 424, in _get_handle f = open(path_or_buf, mode, encoding=encoding, newline="") IsADirectoryError: [Errno 21] Is a directory: '/Users/Pablo/Desktop/SP' RE: Final df to csv - Yoriz - Apr-19-2019 Try adding a filename final_df.to_csv("/Users/Pablo/Desktop/SP/filename_here.csv") |