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

Average Previous and Current Row - Pandas
seaborn pointplot above swarmplot
Edit field and append value to a python dataframe column
column_stack returns non cotiguous array
pandas: conditionally select a row cell for each column based on a mask
pandas custom function apply on melted dataframe
How to check for boolean codition in pandas dataframe
Reading batches of data from BigQuery into Datalab
Jupyter/ipywidgets sorting dataframe on two levels
Groupby.sum() giving ValueError: overflow in timedelta operation
Why does DataFrameGroupBy.boxplot method throw error when given argument “subplots=True/False”?
Calculate age in months - optimize date transformations in pandas
pandas: list of dictionaries grouped by key from df
Pandas data frames and matplotlib.pyplot
Pandas.to_csv thousand separator
Annotating a graph with certain values of another series (Index is datetime)

Categories

HOME
arduino-uno
debugging
netbeans
comparison
relative-path
dot
jsp-tags
alpha
datastax-java-driver
append
cross-validation
webrequest
applepay
medical
floating-action-button
export-to-csv
resize
size
vaadin7
opentracing
ghc
after-effects
reactcsstransitiongroup
http-status-code-504
scichart
clickonce
physics-engine
extjs5
fgetcsv
objectanimator
primitive
quote
contact-form
google-qpx-express-api
perlin-noise
nssegmentedcontrol
bower-install
dartium
hot-module-replacement
streamsets
reportbuilder
android-fingerprint-api
fedex
netcdf4
flashair
errordocument
blogengine.net
powercli
veracode
jxcore
ifs
lync-client-sdk
mediaelement
heidisql
probability-density
skobbler-maps
lttng
flash-cs5
pagedlist
bgp
yaws
jms2
tmuxinator
libressl
content-length
security-testing
map-projections
processmodel
ami
angular-local-storage
skos
tween
javafx-webengine
codeigniter-routing
googlemock
rdl
php-5.4
google-reader
ceil
starcluster
expected-exception
braille
tidy
jplaton
interface-orientation
itmstransporter
simba
coderush
parametric-equations
code-cleanup
bigcouch
custom-backend
php-parser
stage
cinema-4d
mongomapper
datareader
thunderbird-lightning
exchange-server-2003

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