안녕하세요! 27강 고급 입력 컨트롤 내용에 관하여 질문 드리고자 합니다. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys # 크롬 드라이버 생성 driver = webdriver.Chrome() # 페이지 이동 driver.get("https://www.naver.com") # 태그 찾기 search = driver.find_element(By.CSS_SELECTOR, "#query") # 문자 입력 search.send_keys('스타트코딩') #순차적 키 입력 search.send_keys(Keys.COMMAND, 'a') MAC OS에서 위와 같은 형태의 코드(전체선택 코드)가 작동하지 않아서, 아래의 코드를 사용하였습니다. from selenium.webdriver.common.action_chains import ActionChains actions = ActionChains(driver) actions.key_down(Keys.COMMAND).send_keys('a').key_up(Keys.COMMAND).perform() 다만, ActionChains 모듈을 사용하였을 때에도, command+a(전체선택), command+c(복사) 까지는 정상적으로 작동했는데, command+v(붙여넣기)의 경우에만 작동하지 않습니다. 혹시 이에 대한 해결 방법이 있을까요?
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 이상치 제거를 df = df[(df[ 'age' ] == df[ 'age' ].astype( int ) ) & df[ 'age' ] > 0 ] 이렇게 하면 틀린건가요? round쓰는게 이해가 안가네요
프로그래밍 시작하기 : 도전! 45가지 파이썬 기초 문법 실습 (Inflearn Original)
1. 질문하시기 전 유사한 질문 이 있는지 검색을 먼저 부탁드려요! 전체 소스코드 를 올려주시면 답변을 빠르게 드릴 수 있어요!(글보다 빨라요) 기초적인 질문은 이미 검색해보시면 사례가 많이 있어요! 문법적인 궁금증은 먼저 구글 검색을 통해서 레퍼런스(메뉴얼)을 읽어보시고 해결하시면 실력 향상 100% 너무 잦은 질문이나 강의와 관련 없는 질문 은 가급적 자제 부탁드려요 ㅠ.ㅠ 2. 답변이 다소 늦을 수도 있어요! 일반적인 근무시간(9 TO 6) 안에는 답변을 드리도록 노력하고 있어요! 문법적인 질문은 먼저 검색을 통해 해결해 보세요! 정확하게 질문해주시면 정확한 답변을 받으실 수 있어요! 늦더라도 꼭 응답은 드리고 있으니, 먼저 검색을 통해 해결해 보세요! random. sample ( population , k , * , counts=None ) Return a k length list of unique elements chosen from the population sequence. Used for random sampling without replacement. random. choices ( population , weights=None , * , cum_weights=None , k=1 ) Return a k sized list of elements chosen from the population with replacement. python 공식 문서에는 sample 함수가 중복 없이 생성한다고 적혀 있는 것 같은데, 강의 자료나 강의 내에서는 choices 함수가 중복 없이 생성한다고 적혀 있어서 문의 드립니다
아래의 코드를 입력하면 다음과 같은 에러가 발생합니다 KeyError : "['name', 'host_name', 'last_review', 'host_id'] not found in axis" 왜 이런 건가요?ㅠㅠ cols = ['name','host_name','last_review','host_id'] print(train.shape) train = train.drop(cols, axis=1) test = test.drop(cols, axis=1) print(train.shape)
레이블 인코딩 시 le = LabelEncoder() for col in cols: le = LabelEncoder() c_train[col = le.fit_transform(..) c_test .... for 문 전에 레이블 인코더를 호출하여 선언하고 for문 내에서 또 하는 이유는 무엇인가요? for문 시작 전 한번만 해 줘도 되는 게 아닌가해서 질문드려 봅니다.
안녕하세요 선생님. 이전 두 질문에 대한 답변이 많은 도움이 되었습니다. 감사합니다. 2133번 문제의 DP 1번 풀이에서 O(N^2) 풀이를 소개해주셨는데 아래와 같이 dp 테이블을 갱신할 때 sum_dp 테이블을 같이 갱신을 해주면 시간복잡도가 O(N)으로 줄일 수 있지 않나 싶어 질문드립니다. N = int(input()) if N % 2 != 0: print(0) else: n = N//2 dp = [1] * (n+1) sum_dp = [1] * (n+1) for i in range(1,n+1): dp[i] = sum_dp[i-1] * 2 + dp[i-1] sum_dp[i] = sum_dp[i-1] + dp[i] print(dp[-1]) 그리고 이건 다른 종류의 질문인데 혹시 그래프 부분이 실제로 코테에 많이 등장하나요? 제가 조금 급하게 준비하고 있는 상태라 이론을 필수 알고리즘2까지만 들어도 될지 아니면 그래프까지 다 들어야될지 고민중입니다. 조언 주시면 감사하겠습니다!
위의 코드를 그대로 입력하고 baseline 코드까지 문제가 없다가 label에서 다음과 같은 에러가 발생했습니다. KeyError Traceback (most recent call last) /usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key) 3804 try: -> 3805 return self._engine.get_loc(casted_key) 3806 except KeyError as err: index.pyx in pandas._libs.index.IndexEngine.get_loc() index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'Gender' The above exception was the direct cause of the following exception: 아래는 입력한 코드입니다. 어떤 부분이 문제일까요? ㅠㅠ #label from sklearn.preprocessing import LabelEncoder for col in cols : le = LabelEncoder() train[col] = le.fit_transform(train[col]) test[col] = le.transform(test[col]) train[cols].head()
안녕하세요. dir 이나 __all 관련해서,,, print(sklearn.__all__) 은 알겠는데요. 그 다음,,, from sklearn.ensemble import RandomForestClassifier 여기서,, randaomforestclassifier 이게 생각이 나지 않을때 이걸 찾을 수 있는 방법은 없는지요?
안녕하세요, 작업형3을 공부하던 중 궁금한 점이 생겨 문의드립니다. 어떤 상황에서 T검정, 카이제곱 검정, 회귀분석, 분산분석(ANOVA)를 수행하는건지 명확히 분류가 잘 안 되는데 위와 같이 T검정, 카이제곱 검정, 회귀분석, 분산분석 중 어떤 것을 수행할지는 문제에서 주어지는 사항일까요? 감사합니다!
train = pd.read_csv('/kaggle/input/working8-2/churn_train.csv') test = pd.read_csv('/kaggle/input/working8-2/churn_test.csv') target = train.pop('TotalCharges') train = pd.get_dummies(train) test = pd.get_dummies(test) from sklearn.model_selection import train_test_split X_tr,X_val,y_tr,y_val = train_test_split(train, target, test_size=0.2, random_state=2022) from sklearn.metrics import mean_absolute_error from sklearn.ensemble import RandomForestRegressor rf = RandomForestRegressor(random_state=2022, max_depth=7, n_estimators=600) rf.fit(X_tr,y_tr) pred = rf.predict(X_val) answer = rf.predict(test) rf.predict(X_val)까지는 잘 예측이 되어, 866.4986350062683의 값을 얻었습니다. 그리하여 마지막으로 본 test파일을 예측하여 제출하려고 하는데, 계속해서 오류가 발생하네요 ㅠㅠㅠ 아래는 에러 코드입니다. ValueError Traceback (most recent call last) Cell In[97], line 14 12 rf.fit(X_tr,y_tr) 13 pred = rf.predict(X_val) ---> 14 answer = rf.predict(test) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:981, in ForestRegressor.predict(self, X) 979 check_is_fitted(self) 980 # Check data --> 981 X = self._validate_X_predict(X) 983 # Assign chunk of trees to jobs 984 n_jobs, _, _ = _partition_estimators(self.n_estimators, self.n_jobs) File /opt/conda/lib/python3.10/site-packages/sklearn/ensemble/_forest.py:602, in BaseForest._validate_X_predict(self, X) 599 """ 600 Validate X whenever one tries to predict, apply, predict_proba.""" 601 check_is_fitted(self) --> 602 X = self._validate_data(X, dtype=DTYPE, accept_sparse="csr", reset=False) 603 if issparse(X) and (X.indices.dtype != np.intc or X.indptr.dtype != np.intc): 604 raise ValueError("No support for np.int64 index based sparse matrices") File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:548, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params) 483 def _validate_data( 484 self, 485 X="no_validation", (...) 489 **check_params, 490 ): 491 """Validate input data and set or check the `n_features_in_` attribute. 492 493 Parameters (...) 546 validated. 547 """ --> 548 self._check_feature_names(X, reset=reset) 550 if y is None and self._get_tags()["requires_y"]: 551 raise ValueError( 552 f"This {self.__class__.__name__} estimator " 553 "requires y to be passed, but the target y is None." 554 ) File /opt/conda/lib/python3.10/site-packages/sklearn/base.py:481, in BaseEstimator._check_feature_names(self, X, reset) 476 if not missing_names and not unexpected_names: 477 message += ( 478 "Feature names must be in the same order as they were in fit.\n" 479 ) --> 481 raise ValueError(message) ValueError: The feature names should match those that were passed during fit. Feature names unseen at fit time: - customerID_CUST0001 - customerID_CUST0002 - customerID_CUST0006 - customerID_CUST0007 - customerID_CUST0008 - ... Feature names seen at fit time, yet now missing: - customerID_CUST0000 - customerID_CUST0003 - customerID_CUST0004 - customerID_CUST0005 - customerID_CUST0009 - ...