Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type question #41

Open
soye-jy opened this issue Jan 25, 2019 · 2 comments
Open

type question #41

soye-jy opened this issue Jan 25, 2019 · 2 comments

Comments

@soye-jy
Copy link

soye-jy commented Jan 25, 2019

When uploading to the Google sheet, all data types are string.
How can I save the type?

@sauravhiremath
Copy link

All the changes made to the dataframe gets saved as <class type = 'string'>
Exporting this to Google Sheets results in the same datatype.
Thus you can use the values of the dataframe regarding it as 'string' datatype.

@mroy-seedbox
Copy link

You can monkey patch the gspread lib (to not save as strings, via the USER_ENTERED option):

    def upload_pandas_df(self, df):
      values = [df.columns.values.tolist()]
      values.extend(df.values.tolist())
      sheet.values_update(
        self.title,
        params = { 'valueInputOption': 'USER_ENTERED' },
        body = { 'values': values }
      )

    gspread.Worksheet.upload_pandas_df = upload_pandas_df

Or use gspread-dataframe instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants