본문 바로가기

Python78

[Python] KivyMD를 사용하여 GUI application 만들기 KivyMD는 Kivy framework기반의 GUI 개발에 도움을 주는 framework입니다. MD는 Material Design을 뜻합니다. 이번 포스팅에서는 Python을 활용하여 간단한 사용법을 알아보겠습니다. Installation pip를 사용하여 다음의 명령으로 간단히 설치를 할 수 있습니다. $ pip install kivymd 이제 사용 준비는 모두 끝났습니다. 첫 번째 앱 만들기 간단한 코드로 첫 번째 application을 만들어 보겠습니다. from kivymd.app import MDApp from kivymd.uix.label import MDLabel class MainApp(MDApp): def build(self): return MDLabel(text="Hello, Wor.. 2022. 9. 9.
[Python] Using PostgreSQL In this posting, we will check out how to use PostgreSQL with Python on MAC. Installation We can simply install PostgreSQL using Homebrew. $ brew install postgresql Then, the default DB named postgres is initialized. You can restart the service at any time with the below command. This is the official guide. https://www.postgresqltutorial.com/postgresql-getting-started/install-postgresql-macos/ h.. 2022. 5. 19.
[Python] Using Telegram Bot API Let's make a telegram chatbot using Python. Creating ChatBot Let's assume that you are using Telegram. If you add BotFather, you can see it below. If you scroll the menu, you can see the all available commands. Let's select the "Create a new bot" menu (/newbot command). Now, give the name of the bot and username. Then, the telegram will give you the API key. The token looks like this. 123456:ABC.. 2022. 5. 13.
[Python] Usage of .env .env file is commonly used for configuration. Python also has 3rd party library for this. Installation It can be installed by pip. $ pip install python-dotenv Create .env File .env file consists of key-value pair. # .env TEST=test TEST_URL=${TEST}.com You can expand the config using ${} syntax. TEST1="test string" TEST2="Test\nString" You can use a value as multiple lines using escape characters.. 2022. 4. 23.
[Python] Pandas Course on Kaggle - 6 This is the solution of pandas course (Renaming and Combining) on Kaggle site. 1. Rename Columns renamed = reviews.rename(columns={'region_1': 'region', 'region_2': 'locale'}) 2. Rename an Index reindexed = reviews.rename_axis('wines', axis='rows') 3. Combine Data Frames combined_products = pd.concat([gaming_products, movie_products]) 4. Combine Data Frames by Index powerlifting_combined = power.. 2022. 1. 22.
[Python] Pandas Course on Kaggle - 5 This is the solution of pandas course (Data Types and Missing Values) on Kaggle site. 1. Get Data Type of Column dtype = reviews.points.dtype # or dtype = reviews["points"].dtype 2. Change Data Type of Column point_strings = reviews.points.astype(str) # or point_strings = reviews.points.astype('str') # or point_strings = reviews["points"].astype(str) # or point_strings = reviews["points"].astype.. 2022. 1. 21.
[Python] Pandas Course on Kaggle - 4 This is the solution of pandas course (Grouping and Sorting) on Kaggle site. 1. Group by Column reviews_written = reviews.groupby('taster_twitter_handle').size() # or reviews_written = reviews.groupby('taster_twitter_handle') .taster_twitter_handle .count() # or reviews_written = reviews.groupby("taster_twitter_handle")[ "taster_twitter_handle" ].count() 2. Group by Column and Sort by Index best.. 2022. 1. 20.
[Python] Pandas Course on Kaggle - 3 This is the solution of pandas course (Summary Functions and Maps) on Kaggle site. 1. median() Function median_points = reviews.points.median() # or median_points = reviews["points"].median() 2. unique() Function countries = reviews.country.unique() # or countries = reviews["country"].unique() 3. value_counts() Function reviews_per_country = reviews.country.value_counts() # or reviews_per_countr.. 2022. 1. 19.
[Python] Pandas Course on Kaggle - 2 This is the solution of pandas course (Indexing, Selecting & Assigning) on Kaggle site. 1. Select the Column desc = reviews["description"] # or desc = reviews.description 2. Select the Column and Row first_description = reviews["description"][0] # or first_description = reviews.description[0] # or first_description = reviews.description.loc[0] # or first_description = reviews.description.iloc[0].. 2022. 1. 17.
[Python] Pandas Course on Kaggle - 1 This is the solution of pandas course (Creating, Reading and Writing) on Kaggle site. Setup import pandas as pd 1. Create a DataFrame fruits = pd.DataFrame( {"Apples": [30], "Bananas": [21]} ) 2. Create a DataFrame with Index fruit_sales = pd.DataFrame( {"Apples": [35, 41], "Bananas": [21, 34]}, index=["2017 Sales", "2018 Sales"] ) 3. Create a Series ingredients = pd.Series( ["4 cups", "1 cup", .. 2022. 1. 15.
[Python] finterstellar를 사용하여 Stochastic으로 주식 매매 시그널 만들기 2021.12.09 - [Python] - [Python] finterstellar를 사용하여 RSI로 주식 매매 시그널 만들기 먼저 finterstellar가 처음이라면 이전 글을 보고 와주세요. Stochastic Stochastic은 최근 N일간 주가 범위 중 현재 주가가 얼마나 높이 있는지를 나타내는 지표입니다. 트레이딩에 이용하기 쉽도록 이 값들로 이동평균값을 구합니다. 이것을 Slow K라고 합니다. Slow K를 이용하여 다시 이동평균값을 구하여 Slow D를 만듭니다. 기본 적으로 14일 간의 주가를 사용하여 stochastic을 구하며, 각각의 이동평균값을 구하기 위한 기간은 3을 사용합니다. 평균회귀 전략으로 사용할 경우, 보통 Slow K가 20보다 낮을 때 매수를 하여 80보다 높을.. 2021. 12. 14.
[Python] finterstellar를 사용하여 Bollinger Band로 주식 매매 시그널 만들기 2021.12.09 - [Python] - [Python] finterstellar를 사용하여 RSI로 주식 매매 시그널 만들기 먼저 finterstellar가 처음이라면 이전 글을 보고 와주세요. Bollinger Band Bollinger Band는 이동평균에 변동성을 결합한 그래프 입니다. Z-Score: 표준 점수 X: 각 데이터 값 µ: 평균 값 σ: 표준편차 즉, X 값이 평균에서 표준편차의 몇 배만큼 떨어져 있는가를 나타내며, 표준편차가 곧 변동성이므로 주가가 변동성 대비 어느 정도 수준에 위치해 있는지를 나타내게 됩니다. 볼린저 밴드의 각각의 선은 다음과 같습니다. 밴드 상단선: N일 간의 이동평균 + k × 표준편차 밴드 중심선: N일 간의 이동평균 밴드 중심선: N일 간의 이동평균 - .. 2021. 12. 12.