본문 바로가기

분류 전체보기15

Python 가상환경 특정 version 설치하기 가상환경 폴더 하나 만들기 cd virtualfolderPython -m venv [가상환경 명]  파이썬 특정버전 pytion -[버전] -m venv [가상환경 명]python -3.12 -m venv [가상환경 명] 가상환경 실행하기가상환경설치폴더/가상환경이름/Scripts/activate 비활성deactivate 생성했던 가상환경 삭제sudo rm -rf 가상환경 명또는 폴더 삭제 2024. 12. 28.
[python] dynamically create variables as objects and associate them with specific values (e.g., worksheets) If you want to dynamically create variables as objects with names like ws_1, ws_2, and so on, and associate them with specific values (e.g., worksheets), you can use a list or a dictionary to store these objects. Here's an example using a dictionary: # Create a dictionary to store worksheet objects worksheet_dict = {} # Create and store worksheet objects for i in range(1, 6): worksheet_name = f'.. 2023. 9. 14.
pandas float .0 remove df = df.round(decimals=0).astype(object) import numpy as np import pandas as pd s = pd.Series([ None, np.nan, '',8.00735e+09, 4.35789e+09, 6.10644e+09]) s_new = s.fillna('').astype(str).str.replace(".0","",regex=False) s_new without_trailing_zeros = string.rstrip('0').rstrip('.') if '.' in string else string 2023. 7. 28.
python 실행 중 key input 받고 종료하기 첫번째 예) import requests import keyboard # Set up a session object to make HTTP requests session = requests.Session() # Set up a variable to store the URL to crawl url = 'https://www.example.com' # Start crawling the website while True: # Check if the user has pressed the 'q' key if keyboard.is_pressed('q'): print('Exiting program...') break # Make a request to the URL response = session.get(url) .. 2023. 4. 25.