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

Pandas — asof() by last on DataFrame
Pandas Column Construction with np.where()
MultiIndex-based indexing in pandas
How to get the number of the most frequent value in a column?
Using pandas.ols on multiple dependent variables at once
Insert 0-values for missing dates within MultiIndex
Reindexing dataframes
pandas access axis by user-defined name
Trouble with groupss and aggregation
Replace MultiIndex's contents with DataFrame columns
What's the `DataFrameGroupBy`-equivalent of `dict.keys`?
How to split a dataframe according to a boolean criterion?
Pandas Rolling Computations on Sliding Windows (Unevenly spaced)
Resampling Minute data
How to get the last n row of pandas dataframe?
Resample time series in pandas to a weekly interval

Categories

HOME
winforms
multithreading
wso2-am
reserved
path-finding
view
jsp-tags
rsync
malloc
packages
binary-tree
fancybox
flyway4
constraint-programming
dacpac
python-unittest
iron-router
crystal-reports-2008
conemu
tokenize
core-text
devops
fish
django-storage
pingfederate
linkerd
ping
atlassian-crucible
instant-messaging
xquery-3.0
google-qpx-express-api
accelerate-framework
ghost4j
dartium
bitbucket-pipelines
x11-forwarding
swift3.0.2
eigenvalue
turbogears
total-commander
import-from-excel
wptoolkit
taffy
dotcover
smartcontracts
strptime
pubmed
powercli
mu
aurelia-validation
brightcove
r-forge
flow-control
spring-mongodb
azure-sdk
log4c
phishing
py2app
gstreamer-0.10
make-install
fadeout
xpath-1.0
freelancer.com-api
srand
lib.web.mvc
cannon.js
embedded-code
android-listview
php-ci
event-bubbling
createprocessasuser
iiviewdeckcontroller
winddk
nsbutton
preferences
internet-connection
srs
apc
ftps
rabl
type-equivalence
cassini-dev
robotics-studio
anonymous-methods
labwindows
twrequest
tridion-worldserver
viewswitcher
getmessage
bubble-chart
pydot
appender
ecl
floating
w3wp.exe
wise
revisions
sector
paul-graham

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