PYTHON4FINANCE Telegram 1065
خلاصه بندی OHLC داده ها با resample
یکی از توابع بسیار کاربردی pandas تابع resample است. به کمک این تابع می توانیم تناوب داده ها را تغییر دهیم. مثلا داده های ساعتی را به داده های روزانه تبدیل کنیم یا داده های روزانه را به هفتگی، ماهانه و سالانه.
یکی از بخش های قشنگ این ماژل تبدیل داده ها به فرمت OHLC است. یعنی داده های مربوط به بازشدن، بالاترین داده، کمترین داده و داده بسته شده. (البته برای بچه های بازار سرمایه این فرمت آشناست، اما برای سایر رشته ها شاید کمی عجیب به نظر برسد)
فرض کنید داده های ساعتی هواشناسی را داریم. می خواهیم دمای هوا در ابتدا و انتهای روز و نیز بالاترین دما و پایین ترین دما را مشخص و رسم کنیم.
با استفاده از resample به راحتی قابل انجام است.
import pandas as pd
import mplfinance as mpf
url="https://python4finance.ir/datafolder/WeatherData.csv"
df=pd.read_csv(url,index_col="Date/Time" , parse_dates=True)
mpf.plot(df.loc["01/01/2012 00:00":"05/01/2012 00:00"]["Temp_C"].resample("D").ohlc(),type="candle",figsize=(16,6),mav=(10))


#پانداس
#pandas
#resample

پایتون برای مالی

🆔 @python4finance
35



tgoop.com/python4finance/1065
Create:
Last Update:

خلاصه بندی OHLC داده ها با resample
یکی از توابع بسیار کاربردی pandas تابع resample است. به کمک این تابع می توانیم تناوب داده ها را تغییر دهیم. مثلا داده های ساعتی را به داده های روزانه تبدیل کنیم یا داده های روزانه را به هفتگی، ماهانه و سالانه.
یکی از بخش های قشنگ این ماژل تبدیل داده ها به فرمت OHLC است. یعنی داده های مربوط به بازشدن، بالاترین داده، کمترین داده و داده بسته شده. (البته برای بچه های بازار سرمایه این فرمت آشناست، اما برای سایر رشته ها شاید کمی عجیب به نظر برسد)
فرض کنید داده های ساعتی هواشناسی را داریم. می خواهیم دمای هوا در ابتدا و انتهای روز و نیز بالاترین دما و پایین ترین دما را مشخص و رسم کنیم.
با استفاده از resample به راحتی قابل انجام است.

import pandas as pd
import mplfinance as mpf
url="https://python4finance.ir/datafolder/WeatherData.csv"
df=pd.read_csv(url,index_col="Date/Time" , parse_dates=True)
mpf.plot(df.loc["01/01/2012 00:00":"05/01/2012 00:00"]["Temp_C"].resample("D").ohlc(),type="candle",figsize=(16,6),mav=(10))


#پانداس
#pandas
#resample

پایتون برای مالی

🆔 @python4finance

BY Python4Finance




Share with your friend now:
tgoop.com/python4finance/1065

View MORE
Open in Telegram


Telegram News

Date: |

The public channel had more than 109,000 subscribers, Judge Hui said. Ng had the power to remove or amend the messages in the channel, but he “allowed them to exist.” Telegram iOS app: In the “Chats” tab, click the new message icon in the right upper corner. Select “New Channel.” Although some crypto traders have moved toward screaming as a coping mechanism, several mental health experts call this therapy a pseudoscience. The crypto community finds its way to engage in one or the other way and share its feelings with other fellow members. The group’s featured image is of a Pepe frog yelling, often referred to as the “REEEEEEE” meme. Pepe the Frog was created back in 2005 by Matt Furie and has since become an internet symbol for meme culture and “degen” culture. End-to-end encryption is an important feature in messaging, as it's the first step in protecting users from surveillance.
from us


Telegram Python4Finance
FROM American