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
  strange error from pandas dataframe djf123 1 338 Jul-27-2020, 05:25 AM
Last Post: scidam
  Pandas DataFrame not updating HelpMePlease 3 296 Jul-11-2020, 07:19 PM
Last Post: jefsummers
  Pandas DataFrame visual Truman 8 367 Jul-10-2020, 06:11 AM
Last Post: hussainmujtaba
  Pandas DataFrame and unmatched column sritsv19 0 289 Jul-07-2020, 12:52 PM
Last Post: sritsv19
  Pandas DataFrame Concatenate problems Kristenl2784 1 217 Jul-01-2020, 01:28 AM
Last Post: hussainmujtaba
  Difference of two columns in Pandas dataframe zinho 2 521 Jun-17-2020, 03:36 PM
Last Post: zinho
  error bars with dataframe and pandas Hucky 4 445 Apr-27-2020, 02:02 AM
Last Post: Hucky
  Python Pandas DataFrame Help AmericanEagle1989 1 283 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 313 Mar-28-2020, 08:27 AM
Last Post: j.crater
  Ordering of pandas DataFrame new_to_python 5 366 Mar-15-2020, 06:08 PM
Last Post: new_to_python

Forum Jump:


Users browsing this thread: 1 Guest(s)