pandas


Pandas DataFrame Column rename error… am I'm being silly?


So I have two DataFrames each with a number of columns, one is from a new lookup table the other is of already known values stored in my database. The only columns with the same name are hash but one has and id and the other has Id (yes bad naming!) I then call:
lookup = lookup.merge(known, on='hash', how='left')
lookup = lookup.rename(columns={'Id':'db_id'})
You know to merge them and to update the names so that I don't have to remember which one is Id and which is id, a few lines earlier I had called
known = known.rename(columns={'Hash':'hash'})
So that I can preform the hash, all is well and good and right with the world. I then go and change my hashing algorithm, update my database and rerun things. Now, the like
lookup = lookup.rename(columns={'Id':'db_id'})
doesn't throw an error but results in a very long error string ending in:
/usr/lib/python2.7/dist-packages/pandas/core/frame.pyc in _apply_standard(self, func, axis, ignore_failures)
4489 # no k defined yet
4490 pass
-> 4491 raise e
4492
4493
TypeError: ("'NoneType' object is not iterable", u'occurred at index hash')
to be stored in lookup, which is you know a problem. If I change my code to:
known = known.rename(columns={'Hash':'hash', 'Id':'db_id'})
lookup = lookup.merge(known, on='hash', how='left')
All is again well and right with the world, except I'm very very confused the way I had it before no longer works.

Related Links

Python pandas json 2D array
rename columns function not working in pandas
Number format column with pandas.DataFrame.to_csv()?
Matplotlib Subplot Labels Disappear
Counting rows between dates in pandas with groupby
Taking second last observed row
retrieve data from pandas dataframe if it doesn't cooccur in previous column
pandas resample MAX-VALUE with corresponding ANGLE-VALUE
Performance issues with writing data to HDFStore
Finding same value index of pandas Series
Get Maximum Value from Dataframe
Slicing in group by function
Grouping factors in python patsy
pandas Series groupby col not found
Annotate labels in pandas scatter plot
Arithmetic in pandas HDF5 queries

Categories

HOME
arduino-uno
pdf
client
osgi
clips
comparison
fft
syntax
electron
jsp-tags
at-command
leon
sharepoint-designer
packages
ojdbc
flyway4
ios-charts
add
slurm
primary-key
rascal
ibm-odm
windows-server-2012
django-simple-history
facebook-page
propel
nhibernate-envers
immutable.js
kudan
claims-based-identity
lcd
crystal-reports-2010
numerical-methods
maxmind
xacml
gitignore
google-rich-snippets
semantic-versioning
airconsole
column-family
openoffice.org
google-api-nodejs-client
mapdb
az-application-insights
jna
dism
galen
nomethoderror
node-sass
executenonquery
skeleton-css-boilerplate
taffy
typescript1.8
sage-one
hls.js
tizen-native-app
svmlight
sqlbulkcopy
cudafy.net
imanage
nested-sets
visual-c++-2008
sts-springsourcetoolsuite
azure-virtual-network
file-writing
login-control
fadeout
yaws
apachebench
two-factor-authentication
xpath-1.0
spim
ideamart
ami
census
bridge.net
inmobi
kineticjs
rake-task
knuth
html-helper
onactivityresult
article
didselectrowatindexpath
html5-notifications
ms-project-server-2010
google-cloud-save
blending
bulkloader
dataadapter
pushbackinputstream
android-screen-support
lcs
cassini-dev
bitsharp
gil
dice
manchester-syntax
twrequest
amazon-appstore
php-parser
pydot
gcj
genshi
f#-powerpack
android-sdk-2.1
yslow
sudzc
digest-authentication
gamequery
mozilla-prism
modelstate
nhibernate.search
nsviewanimation
castle-monorail
photoshop-cs4
javap
temporal-database
grid-system

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App