Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Pandas Dataframe to Google Big Query
#1
Hiya,

Just when I almost get it, it slips away.

I have a dataframe that I would like to put into a google big query table.
However (aha) as per normal, when I try it, it just errors (pyarrow cannot convert byte to intger on an object/string).

So I thought I would try to force a type on a column on the dataframe to see if that would allow it to go up.
Can't even get that to work.
df.reset_index()
df.rename(mapper={ 
    'year':'theyear', 'month':'themonth', 
    'excl':'totalexclbtw','incl':'totalinclbtw',
    'autotrading':'automatedtrading'
    }, axis='columns',inplace=True)
df[ 'dateofprocesing' ] = None
df[ 'publisherid' ] = 0
df[ 'siteid' ] = 0
df.astype([{'theyear':'int64'},{'themonth':'int64'}], copy=False, errors='raise')

df.dtypes
The month and the year should all be numbers, but appears it has been assigned an object (assuming string)

How do I change the type of the column..?
Quote
#2
If you would have looked here you´d seen that you need to provide a dictionary and not a list of column names.
df.astype({'theyear':'int64', 'themonth':'int64'}, copy=False)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  manipulating a dataframe - pandas nsx200 2 100 Nov-14-2019, 10:38 AM
Last Post: nsx200
  Pandas dataframe columns collapsed in Spyder when printing UniKlixX 2 112 Nov-04-2019, 07:00 AM
Last Post: UniKlixX
  pandas dataframe iloc mystery edvvardbrian 2 177 Oct-29-2019, 02:55 PM
Last Post: jefsummers
  Need help passing date to pandas query curranjohn46 1 174 Oct-10-2019, 09:59 AM
Last Post: curranjohn46
  How to add a few empty rows into a pandas dataframe python_newbie09 2 536 Sep-20-2019, 08:52 AM
Last Post: python_newbie09
  Dropping a column from pandas dataframe marco_ita 6 742 Sep-07-2019, 08:36 AM
Last Post: marco_ita
  created a pandas series instead of pandas DataFrame ibaad1406 6 598 Sep-06-2019, 06:23 AM
Last Post: ibaad1406
  Applying operation to a pandas multi index dataframe subgroup Nuovoq 1 353 Sep-04-2019, 10:04 PM
Last Post: Nuovoq
  Substr on Pandas Dataframe Scott 1 398 Sep-02-2019, 02:49 AM
Last Post: scidam
  how to apply user defined function to Pandas DataFrame evelynow 3 675 Aug-20-2019, 11:35 PM
Last Post: scidam

Forum Jump:


Users browsing this thread: 1 Guest(s)