Coder Social home page Coder Social logo

Comments (4)

robin900 avatar robin900 commented on May 23, 2024

I do not understand what behavior you desire. Are you saying that you would like to skip over two columns of the dataframe when writing to the worksheet? But also somehow skipping over two columns in the worksheet so that those two columns in the sheet are unaffected by the dataframe cells being written?

from gspread-dataframe.

robin900 avatar robin900 commented on May 23, 2024

Just guessing here, but if you only wish to write some column or columns of a dataframe to a worksheet, derive a second dataframe that contains just the column or columns to write; then use parameters for set_as_dataframe that allow you to offset the column, etc.:

def set_with_dataframe(
    worksheet,
    dataframe,
    row=1,
    col=1,
    include_index=False,
    include_column_header=True,
    resize=False,
    allow_formulas=True,
    string_escaping="default"):

from gspread-dataframe.

MrBeardedGuy avatar MrBeardedGuy commented on May 23, 2024

My bad. Too little description :)
I'm thinking of a scenario where a dataframe gets appended to a worksheet with some data in it. The action might result in duplicated cols or rows that need to be dropped (impossible to predict which ones though).

Appending can be easily done by passing the option row=last_row_of_sheet_data+1 to the set_with_dataframe

I was wondering if set_with_dataframe could have an option to remove the duplicated values in case the worksheet already has some data. Similar to what Panda's drop duplicates does.

from gspread-dataframe.

robin900 avatar robin900 commented on May 23, 2024

The most successful approach in using the gspread-dataframe package is:

  1. Read the contents of a worksheet into a DataFrame.
  2. Modify the DataFrame as desired. Add data, drop duplicates, remove columns, etc.
  3. Write the resulting DataFrame to a worksheet, replacing the entire contents of the worksheet.

I expect that this approach will serve your DataFrame writing needs. If you encounter in the future a specific situation where the above approach isn't sufficient, feel free to open another issue.

from gspread-dataframe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.