Financial Data Science Financial Performance Analysis: Difference between revisions
Jump to navigation
Jump to search
Line 21: | Line 21: | ||
# extract a specific time series and plot it | # extract a specific time series and plot it | ||
fidelity_self_managed = df[''].apply(dollar_to_int) | fidelity_self_managed = df[''].apply(dollar_to_int) | ||
# graph | |||
fig, ax = plt.subplots() | |||
fig.autofmt_xdate() | |||
ax.set_ylabel("amount") | |||
ax.yaxis.set_major_formatter(mt.FormatStrFormatter('% 1.2f')) | |||
ax.plot(fidelity_self_managed) | |||
plt.show() | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 22:53, 20 October 2023
Internal
Overview
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as ptick
# load the DataFrame
df = pd.read_csv("./data.csv", parse_dates=["date"])
# make it a time series DataFrame
df.set_index('date')
# declare the function that converts the dollar amount
def dollar_to_int(s: str):
return int(s[1:].replace(',',''))
# extract a specific time series and plot it
fidelity_self_managed = df[''].apply(dollar_to_int)
# graph
fig, ax = plt.subplots()
fig.autofmt_xdate()
ax.set_ylabel("amount")
ax.yaxis.set_major_formatter(mt.FormatStrFormatter('% 1.2f'))
ax.plot(fidelity_self_managed)
plt.show()