安装最新的Mac OSX 64位Anaconda Python发行版后,我在尝试启动IPython Notebook时不断收到ValueError.
启动ipython工作正常:
3-millerc-~:ipython
Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Run Code Online (Sandbox Code Playgroud)
但是启动ipython笔记本:
4-millerc-~:ipython notebook
Run Code Online (Sandbox Code Playgroud)
ValueError中的结果(带回溯):
Traceback (most recent call last):
File "/Users/millerc/anaconda/bin/ipython", line 7, in <module>
launch_new_instance()
File "/Users/millerc/anaconda/lib/python2.7/site-packages/IPython/frontend/terminal/ipapp.py", …
Run Code Online (Sandbox Code Playgroud) compare
我在 Pandas 文档中找到了该函数:
pandas.DataFrame.compare
DataFrame.compare(other, align_axis=1, keep_shape=False, keep_equal=False)
Run Code Online (Sandbox Code Playgroud)
def New_names(self, df_old, df_new):
#New records for insert
df_old_names = set(df_old['name'])
df_new_names = set(df_new['name'])
difference = df_new_names - df_old_names
coincidence = df_old_names - difference
exit_insert = df_new[df_new['name'].isin(difference)]
#Check old records
df_old_names_restrict = df_old[df_new.columns]
exit_update = df_new.compare(df_old_names_restrict)
return (exit_insert, exit_update)
Run Code Online (Sandbox Code Playgroud)
但它会引发以下错误:
Traceback (most recent call last): File
"C:/Users/shulya403/Shulya403_works/all_gid_2/Database/db_insert_pd.py",
line 203, in <module>
FillDB.Pruducts_to_SQL(df_new=FillDB.df_Products.head(20)) File "C:/Users/shulya403/Shulya403_works/all_gid_2/Database/db_insert_pd.py",
line 184, in Pruducts_to_SQL
df_select = self.New_names(self.Select_SQL_Products(), df_new)[0] File
"C:/Users/shulya403/Shulya403_works/all_gid_2/Database/db_insert_pd.py",
line 175, in New_names
exit_update = …
Run Code Online (Sandbox Code Playgroud)