Links

Format number to string

Tags: #pandas #dataframe #format #snippet #yahoofinance #naas_drivers #operations #jupyternotebooks
Author: Florent Ravenel
Description: This notebook provides an example of how to convert numerical values to strings using the Pandas library.

Input

Import libraries

from naas_drivers import yahoofinance

Input parameters

ticker = "TSLA"
date_from = -100
date_to = "today"

Model

Get dataframe from Yahoo Finance

df_yahoo = yahoofinance.get(ticker, date_from=-5)
df_yahoo

Output

Format number nicely

Get more information in the doc here
df_yahoo["VALUE"] = df_yahoo["Close"].map("€ {:,.2f}".format).str.replace(",", " ")
df_yahoo