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

Combine two columns of numbers in dataframe into single column using pandas/python
Python Pandas has low CPU usage and not using all cores
Pandas Set on copy warning when using .loc
Merge very large csv using pandas or awk
seasonal_decompose: operands could not be broadcast together with shapes on a series
How to properly sample from a numpy.random.multivariate_normal (positive-semidefinite covariance matrix issue)
how to do logical operation between dataframe columns?
Console hangs up at the time of plotting
Pandas apply a function at fixed interval
float type column in pandas to convert to tuple/list
Getting an error with Pandas Panel boolean indexing
pandas dataframe subtraction causing nan
Pandas dataframe: truncate string fields
how to add new categorical column in pandas
Finding different Ids with the same value in pandas dataframe
Why can't iterrows do math - and instead returns integer values where these should be floats

Categories

HOME
keycloak
urbancode
nullpointerexception
platform-builder
tesseract
read-eval-print-loop
spring-jdbc
sharepoint-designer
baqend
yum
amazon-cloudformation
windows-10-universal
node-pdfkit
mapserver
modelica
visual-studio-2005
iron-router
decimal
percona
uitypeeditor
apache-metamodel
pythonanywhere
jtextfield
excel-2007
extjs5
telerik-reporting
icloud-api
url-scheme
opentype
atlassian-crucible
windowbuilder
http-status-code-503
android-kernel
main
dosbox
jquery-bootgrid
abstract-class
code-search-engine
unspecified
unobtrusive-validation
webdriver-manager
particles.js
core-plot
spring-security-kerberos
turbogears
mime
import-from-excel
.net-4.6.2
btrace
osx-mavericks
strptime
theming
boost-multi-index
nativeapplication
slickedit
boost-preprocessor
pearson
spring-mongodb
wdf
login-control
websitepanel
sigabrt
captivenetwork
oauth2client
revolution-r
xpath-1.0
associative-array
reactive-banana
feedback
ibaction
ideamart
cisco-ios
device-orientation
titanium-modules
has-many-through
aapt
kgdb
mechanize-ruby
rtmfp
java.nio.file
geos
tidy
dotnetnuke-5
itmstransporter
nsnetservice
word-processor
code-cleanup
appendto
ecl
android-sdk-2.1
sql-server-profiler
imac
routedevent
bespin
libs
privilege
phonon

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