python - Concatenating pandas DataFrames with datetime columns -
i'm trying concatenate 2 dataframes (called firstdata , lastdata) created sql queries. however, when try concatenate them, error says typeerror: can't compare datetime.datetime int
. judging message, i'm thinking issue concatenation authorized field. dummy data data frame looks below. thoughts on how around this?
print firstdata order_id email ip authorized 0 1234567 dummy@dummy.net x.x.x.x 2008-11-15 19:16:07 1 8911234 dummy@dummy.com x.x.x.x 2008-11-15 17:59:55 2 4567833 dummy@dummy.com x.x.x.x 2008-11-15 17:50:20 hour day_of_week shipment_type zips_match merch_subcat 0 19 7 standard 1 accessory 1 17 7 standard 1 accessory 2 17 7 standard 1 kid toy/clothes print lastdata order_id email ip authorized 3 1234567 dummy@dummy.net x.x.x.x 2008-11-15 17:43:13 4 8901234 dummy@dummy.com x.x.x.x 2008-11-15 13:18:01 5 4567890 dummy@dummy.com x.x.x.x 2008-11-15 09:29:10 hour day_of_week shipment_type zips_match merch_subcat 3 17 7 standard 1 bag 4 13 7 standard 1 paperweight/boxes 5 09 7 standard 0 candle concat(firstdata, lastdata) typeerror: can't compare datetime.datetime int
you need pass list
, dict
, tuple
, or generator of dataframe
or series
objects concat
. you're doing throw typeerror
because lastdata
being passed axis
argument (and there numerous lines axis == 0
, trigger typeerror
). this:
in [31]: out[31]: 0 1 2 3 4 5 0 0 1234567 dummy@dummy.net x.x.x.x 2008-11-15 19:16:07 1 1 8911234 dummy@dummy.com x.x.x.x 2008-11-15 17:59:55 2 2 4567833 dummy@dummy.com x.x.x.x 2008-11-15 17:50:20 in [32]: b out[32]: 0 1 2 3 4 5 0 3 1234567 dummy@dummy.net x.x.x.x 2008-11-15 17:43:13 1 4 8901234 dummy@dummy.com x.x.x.x 2008-11-15 13:18:01 2 5 4567890 dummy@dummy.com x.x.x.x 2008-11-15 09:29:10 in [33]: concat([a, b]) out[33]: 0 1 2 3 4 5 0 0 1234567 dummy@dummy.net x.x.x.x 2008-11-15 19:16:07 1 1 8911234 dummy@dummy.com x.x.x.x 2008-11-15 17:59:55 2 2 4567833 dummy@dummy.com x.x.x.x 2008-11-15 17:50:20 0 3 1234567 dummy@dummy.net x.x.x.x 2008-11-15 17:43:13 1 4 8901234 dummy@dummy.com x.x.x.x 2008-11-15 13:18:01 2 5 4567890 dummy@dummy.com x.x.x.x 2008-11-15 09:29:10 in [34]: concat([a, b], axis=1) out[34]: 0 1 2 3 4 5 0 1 \ 0 0 1234567 dummy@dummy.net x.x.x.x 2008-11-15 19:16:07 3 1234567 1 1 8911234 dummy@dummy.com x.x.x.x 2008-11-15 17:59:55 4 8901234 2 2 4567833 dummy@dummy.com x.x.x.x 2008-11-15 17:50:20 5 4567890 2 3 4 5 0 dummy@dummy.net x.x.x.x 2008-11-15 17:43:13 1 dummy@dummy.com x.x.x.x 2008-11-15 13:18:01 2 dummy@dummy.com x.x.x.x 2008-11-15 09:29:10
this raises assertionerror
, since commit 36142334
(which in v0.12.0 release) won't cryptic error anymore.
Comments
Post a Comment