Category : methods

I’m trying to prompt a user to input a column name in a pandas dataframe and then use that input to display information about the column. the code I’ve tried: df = #initializing dataframe user_input = input(‘enter column name’) print(df.user_input.describe()) but I got the error: df has no attribute user_input assuming that user input is ..

Read more

I want to understand the structure of sklearn’s LinearRegression() as a python class. In particular, this is how a typical usage might look like: from sklearn.linear_model import LinearRegression model = LinearRegression() #we initialize the class model.fit(X, y) predicted_values = model.predict(test_data) Now, there are a bunch of things we do. First we initialize the class LinearRegression() ..

Read more

Suppose I have a function with a variable drinks whose values might be extended later on: def what_to_drink(drinks): assert drinks in [‘coffee’,’tea’], "Invalid ‘drink’ value. Please choose between ‘coffee’ or ‘tea’." if drinks == ‘coffee’: print("I don’t drink coffee, I drink tea my dear") elif: drinks == ‘tea’: print("I am an English man in New ..

Read more

I found this piece of code in this repo. https://github.com/adw0rd/instagrapi/blob/master/instagrapi/mixins/fbsearch.py And I wonder how self.private_request() could be called because there is no import and private_request() isn’t defined in this class. from instagrapi.extractors import extract_location class FbSearchMixin: def fbsearch_places(self, query: str, lat: float = 40.74, lng: float = -73.94): params = { ‘search_surface’: ‘places_search_page’, ‘timezone_offset’: self.timezone_offset, ..

Read more