Telegram Group & Telegram Channel
خلاصه بندی OHLC داده ها با resample
یکی از توابع بسیار کاربردی pandas تابع resample است. به کمک این تابع می توانیم تناوب داده ها را تغییر دهیم. مثلا داده های ساعتی را به داده های روزانه تبدیل کنیم یا داده های روزانه را به هفتگی، ماهانه و سالانه.
یکی از بخش های قشنگ این ماژل تبدیل داده ها به فرمت OHLC است. یعنی داده های مربوط به بازشدن، بالاترین داده، کمترین داده و داده بسته شده. (البته برای بچه های بازار سرمایه این فرمت آشناست، اما برای سایر رشته ها شاید کمی عجیب به نظر برسد)
فرض کنید داده های ساعتی هواشناسی را داریم. می خواهیم دمای هوا در ابتدا و انتهای روز و نیز بالاترین دما و پایین ترین دما را مشخص و رسم کنیم.
با استفاده از resample به راحتی قابل انجام است.
import pandas as pd
import mplfinance as mpf
url="https://us/Python4Finance/com.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



tg-me.com/python4finance/1065
Create:
Last Update:

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

import pandas as pd
import mplfinance as mpf
url="https://us/Python4Finance/com.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:
tg-me.com/python4finance/1065

View MORE
Open in Telegram


Python4Finance Telegram | DID YOU KNOW?

Date: |

Newly uncovered hack campaign in Telegram

The campaign, which security firm Check Point has named Rampant Kitten, comprises two main components, one for Windows and the other for Android. Rampant Kitten’s objective is to steal Telegram messages, passwords, and two-factor authentication codes sent by SMS and then also take screenshots and record sounds within earshot of an infected phone, the researchers said in a post published on Friday.

Telegram Be The Next Best SPAC

I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.

Python4Finance from us


Telegram Python4Finance
FROM USA