합계, 길이, 개수 이런식으로 문제에 명시되지 않고 데이터 수를 구하여라 이런 식으로 적혀있을 때, sum이 사용된 적도 있고 len이 사용된 적도 있는데 sum(), len(), count() 각각 언제 사용되는지 궁금합니다 수치형, 범주형에 따른 사용 가능 여부 차이도 있나요??
code: import time, random import data import uiautomator2 as u2 serial = "********" device = u2.connect(serial) device(resourceId="com.instagram.android:id/row_feed_button_like").click() 실행 시 오류 C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe C:/Users/user/Desktop/pythonProject1/insta/ momobiletest.py Traceback (most recent call last): File "C:\Users\user\Desktop\pythonProject1\insta\momobiletest.py", line 8, in <module> device(resourceId="com.instagram.android:id/row_feed_button_like").click() File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\uiautomator2\_selector.py", line 149, in click self.must_wait(timeout=timeout) File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\uiautomator2\_selector.py", line 344, in must_wait raise UiObjectNotFoundError({'code': -32002, 'data': str(self.selector), 'method': 'wait'}) uiautomator2.exceptions.UiObjectNotFoundError: {'code': -32002, 'data': "Selector [resourceId='com.instagram.android:id/row_feed_button_like']", 'method': 'wait'} uiautomator2 버전은 3.0.10 adbutils 버전은 2.6.2 왜 계속 오류가 뜨고 안되는지 모르겠습니다.
선생님! iloc같은경우 인덱스값은 그 앞에 까지 뽑기때문에 +1 해주는 범위까지 설정 해 주는것인데, 컬럼 번호 쓸때는 해당 없는거 같네요?! quiz 2번 푸는데 iloc로 메뉴~할인율 까지 할때 범위를 :3으로 하시길래요! 위에 설명할때는 iloc때 범위를 :로 나타낼 때 마지막을 포함하지 않는다고 하셨는데, 인덱스만 포함하지 않는게 맞는거죠?
[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)
안녕하세요 수업 듣는중 문제 푸는 21번 강의에서 'str' object is not callable 나와서 알려주신대로 코드를 작성했다가, 안되서 강의자료 복사에서 실행해도 error 납니다. 이런 경우에는 왜 이런 버그가 나오나요? 문제를 풀다가 1번도 아니고 여러 문제들이 계속 같은 문구가 나와서 이렇게 문의드립니다. 답변 주시면 감사하겠습니다 수업 21번 - 본 강의 영상 학습 관련 문의에 대해 답변을 드립니다. (어떤 챕터 몇분 몇초를 꼭 기재부탁드립니다) - 이외의 문의등은 평생강의이므로 양해를 부탁드립니다 - 현업과 병행하는 관계로 주말/휴가 제외 최대한 3일내로 답변을 드리려 노력하고 있습니다 - 잠깐! 인프런 서비스 운영(다운로드 방법포함) 관련 문의는 1:1 문의하기를 이용해주세요.
import openai api_key = " " openai.api_key = api_key def ask_gpt(system, prompt, model="gpt-3.5-turbo"): completion = openai.ChatCompletion.create( model=model, messages=[ {"role": "system", "content": system}, {"role": "user", "content": prompt} ], stream=True ) result = "" for chunk in completion: delta_data = chunk.choices[0].delta if 'role' in delta_data: continue elif 'content' in delta_data: r_text = delta_data['content'] result += r_text print(r_text, end="",flust=True) ask_gpt(system="you are a helpful assistant." , prompt="사과에 관한 글을 써줘") 해당 부분이 작동이 되지 않아서 확인 요청드립니다. api_key 값은 일단 빼두었습니다.
1.5 groupby 까지 안막히고 잘 오다가 여기서 막힙니다. df_last.groupby(["지역명"]).mean() 작성했을때 TypeError: agg function failed [how->mean,dtype->object] 에러가 뜹니다. 그런데 이어서 ["평당분양가격"]을 타이핑 하면 정상 결과가 나옵니다. 무슨 문제일까요.,?
수치형은 robustscaler를 사용하려고 하는데여 from sklearn.preprocessing import RobustScaler scaler = RobustScaler() cols = x_train.select_dtypes(exclude='object') for col in cols: x_train[col] = scaler.fit_transform(x_train[col]) x_test[col] = scaler.transform(x_test[col]) 이렇게 하면 ,ValueError: Expected 2D array, got 1D array instead: array=[ 888. 1308. 151. ... 173. 1244. 893.]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. 이런 오류가 납니다... 어떻게 수정해야 하나여
안녕하세요. 외부 파이썬 함수 수행하기가 안되어서 문의드리게 되었습니다. 저는 Pycharm이 익숙해서 Pycharm으로 하고 있었는데, Pycharm의 경우 .env파일이 인식이 안되는 걸까요..? common 모듈을 발견하지 못하네요... .env파일을 아래와 같이 설정하였고 dags_python_import_ func.py 에서도 Enable EnvFile에 체크표시를 하였는데 여전히 해당 모듈을 읽지 못하네요...ㅠㅠ 혹시 Pycharm의 경우 .env파일을 다르게 설정해야하는 걸까요...?
안녕하세요! 차근차근 잘 보고 있습니다. 선생님이랑 똑같이 따라하고 있는데 저는 자꾸 에러가 나서요ㅠㅠ ".logo_naver"가 없어진거 같아서 다른걸 붙여서 했는데도 오류가 나는데 뭐가 잘못된 걸까요ㅠㅠㅠㅠ 답변이 선생님이랑은 다르게 이렇게 나와서요ㅠㅠ 똑같이 따라하는데 뭐가 잘못된 건지 모르겠어요ㅠㅠ
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 안녕하세요! 쌤 인프런, 유튜브 강의 보면서 잘 만들어 가고 있었는데 현재 코드에서 아무리 수정을 해도 css를 잘못 가져오는건지 오류가 생겨서 답답해서 질문 들고 왔습니다 현재 css 코드 찾기 좀 부탁드릴게요ㅠㅠ 안되는 항목 ✔ 연예뉴스 -> 내용을 못 가져옴 ✔ 스포츠뉴스 -> 제목, 날짜, 내용 다 못 가져옴 css를 여러개 바꿔서 넣어봐도 저는 자꾸 찾을 수 없다고 크롤링 됩니다 도와주세요,,,,,,, #네이버기사 크롤링 엑셀저장 import requests from bs4 import BeautifulSoup import time import pyautogui from openpyxl import Workbook #사용자입력 keyword = pyautogui.prompt("검색어를 입력하세요") lastpage = int(pyautogui.prompt("몇 페이지까지 크롤링 할까요?")) #엑셀 생성 wb = Workbook() #엑셀시트 생성 ws = wb.create_sheet(keyword) #열 너비 조절 ws.column_dimensions['A'].width = 60 ws.column_dimensions['B'].width = 30 ws.column_dimensions['C'].width = 60 ws.column_dimensions['D'].width = 150 #행 번호 row = 1 #페이지 번호 pageNum = 1 for i in range(1, lastpage*10, 10) : print(f"{pageNum}페이지 크롤링중입니다 =================") response = requests.get(f"https://search.naver.com/search.naver?where=news&query={keyword}&sm=tab_opt&sort=1&photo=0&field=0&pd=3&ds=2024.04.11&de=2024.15.20&news&query={keyword}&start={i}") html = response.text soup = BeautifulSoup(html, 'html.parser') articles = soup.select("div.info_group") #뉴스기사 div 10개 추출 for article in articles: links = article.select("a.info") #리스트 time.sleep(0.7) if len(links) >= 2: #링크가 2개 이상이면 url = links[1].attrs['href'] #두번째 링크의 href를 추출 response = requests.get(url, headers={'User-agent': 'Mozilla/5.0'}) html = response.text soup_sub = BeautifulSoup(html, 'html.parser') content = soup_sub.select_one("#newsct_article") if content: content_text = content.get_text(separator="\n") else: content_text = "내용을 찾을 수 없습니다." title = None date = None #만약 연예 뉴스라면 if "entertain" in response.url: title = soup_sub.select_one(".end_tit") date = soup_sub.select_one("div.article_info > span > em") content = soup.select_one("#articeBody") #만약 스포츠 뉴스라면 elif "sports" in response.url: title = soup_sub.select_one(".Main_article_title") content = soup.select_one("._article_content") else: title = soup_sub.select_one(".media_end_head_headline") date = soup_sub.select_one("span.media_end_head_info_datestamp_time._ARTICLE_DATE_TIME") #본문 내용안에 불필요한 div, p제거 divs = content.select("div") for div in divs: div.decompose() paragraphs = content.select("p") for p in paragraphs: p.decompose() print("=======제목======= \n", title.text.strip() if title else "제목을 찾을 수 없습니다.") print("=======날짜======= \n", date.text if date else "날짜를 찾을 수 없습니다.") print("=======URL======= \n", url) print("=======내용======= \n", content.text.strip() if content else "내용을 찾을 수 없습니다") # 'else' 블록에서 'date' 변수 정의는 여기서 끝나도록 수정 ws['A1'] = '제목' ws['B1'] = '날짜' ws['C1'] = 'URL' ws['D1'] = '내용' ws[f'A{row}'] = title.text.strip() if title else "제목을 찾을 수 없습니다." ws[f'B{row}'] = date.text.strip() if date else "날짜를 찾을 수 없습니다." ws[f'C{row}'] = url ws[f'D{row}'] = content_text.strip() if content else "내용을 찾을 수 없습니다." row=row+1 #마지막 페이지 여부 확인하기 next_button = soup.select_one("a.btn_next") if next_button: isLastPage = next_button.attrs.get('aria-disabled', None) if isLastPage == 'true': print("마지막 페이지 입니다.") break pageNum = pageNum+1 wb.save(f"{keyword}_4월_뉴스기사_크롤링(4)_내용까지_0411~0415(3).xlsx")