python - I'm still learning A.I and trying to create a Linear Regression algorithm model, but I keep getting KeyError when trying to pop a column - TagMerge
1I'm still learning A.I and trying to create a Linear Regression algorithm model, but I keep getting KeyError when trying to pop a columnI'm still learning A.I and trying to create a Linear Regression algorithm model, but I keep getting KeyError when trying to pop a column

I'm still learning A.I and trying to create a Linear Regression algorithm model, but I keep getting KeyError when trying to pop a column

Asked 1 years ago
-1
1 answers

If you want to export the contents of a Google Sheets spreadsheet, you can use the suggestion in this answer.

In your case, you're using Pandas, so you don't need to use the requests package.

So you can define this function:

def get_docs_url(doc_id):
    url = f"https://docs.google.com/spreadsheet/ccc?key={doc_id}&output=csv"
    return url

And use it like this:

train = get_docs_url('1qQfNL2ePWVsOiqSNgJu_ZwmI9KFwFTrtdb1boqIKFZQ')
dftrain = pd.read_csv(train) # training data

PS: I removed the sep='\t,\s*' part because it's not needed to parse a CSV file.

PPS: The test dataset has different column names than the train dataset. I needed to add dfeval = dfeval.rename(columns={'X': 'xvalue', 'Y': 'yvalue'}) to get it to work.

Source: link

Recent Questions on python

    Programming Languages