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
#3
Thank you.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  error bars with dataframe and pandas Hucky 4 279 Apr-27-2020, 02:02 AM
Last Post: Hucky
  Python Pandas DataFrame Help AmericanEagle1989 1 181 Apr-12-2020, 12:37 PM
Last Post: AmericanEagle1989
  How does pyplot know what was plotted by the output of pandas.DataFrame(...).cumprod( codeowl 2 194 Mar-28-2020, 08:27 AM
Last Post: j.crater
  Ordering of pandas DataFrame new_to_python 5 270 Mar-15-2020, 06:08 PM
Last Post: new_to_python
  Pandas dataframe merge snmmat 1 257 Mar-09-2020, 06:56 PM
Last Post: jefsummers
  Transform Facebook Graph API insights JSON to pandas dataframe usman 0 274 Mar-03-2020, 05:14 AM
Last Post: usman
  Obtaining Correct Date In Pandas DataFrame eddywinch82 14 1,392 Feb-17-2020, 11:45 AM
Last Post: eddywinch82
  Parse XML String in Pandas Dataframe creedX 2 941 Dec-09-2019, 07:35 PM
Last Post: creedX
  Pandas dataframe to join three tables using like condition among them sandeep_ganga 0 406 Nov-29-2019, 08:30 AM
Last Post: sandeep_ganga
  manipulating a dataframe - pandas nsx200 2 372 Nov-14-2019, 10:38 AM
Last Post: nsx200

Forum Jump:


Users browsing this thread: 1 Guest(s)