Error: Line magic function

假如想象 提交于 2019-12-05 19:58:46

问题


I'm trying to read a file using python and I keep getting this error

ERROR: Line magic function `%user_vars` not found.

My code is very basic just

names = read_csv('Combined data.csv')
names.head()

I get this for anytime I try to read or open a file. I tried using this thread for help.

ERROR: Line magic function `%matplotlib` not found

I'm using enthought canopy and I have IPython version 2.4.1. I made sure to update using the IPython installation page for help. I'm not sure what's wrong because it should be very simple to open/read files. I even get this error for opening text files.

EDIT:

I imported traceback and used

 print(traceback.format_exc())

But all I get is none printed. I'm not sure what that means.


回答1:


Looks like you are using Pandas. Try the following (assuming your csv file is in the same path as the your script lib) and insert it one line at a time if you are using the IPython Shell:

import pandas as pd 
names = pd.read_csv('Combined data.csv')
names.head()


来源:https://stackoverflow.com/questions/31735624/error-line-magic-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!