can you give me salesforce stock price and revenue on 1 chart. But put the ttm revenue against same dates on the chart. So like stock prices, each dates have correspending revenue
can you give me salesforce stock price and revenue on 1 chart. But put the ttm revenue against same dates on the chart. So like stock prices, each dates have correspending revenue
Calling: load
- metrics=["close", "total_revenue"], tickers=["CRM"]
Calling: compute
- dataframe_ids=[150, 151], code="df = df_151[df_151['period_type'] == 'quarterly'].sort_values('date')\ndf['ttm_revenue'] = df.groupby('ticker')['total_revenue'].rolling(window=4).sum().reset_index(0, drop=True)\n\n# Merge with price\nmerged = pd.merge_asof(df_150.sort_values('date'), df[['date', 'ttm_revenue']].sort_values('date'), on='date', direction='backward')\nresult = merged"
Error: Python error: ocal/lib/python3.11/dist-packages/pandas/core/reshape/merge.py", line 2353, in __init__
_OrderedMerge.__init__(
File "/usr/local/lib/python3.11/dist-packages/pandas/core/reshape/merge.py", line 2265, in __init__
_MergeOperation.__init__(
File "/usr/local/lib/python3.11/dist-packages/pandas/core/reshape/merge.py", line 1010, in __init__
self.left_on, self.right_on = self._validate_left_right_on(left_on, right_on)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pandas/core/reshape/merge.py", line 2426, in _validate_left_right_on
raise MergeError(
pandas.errors.MergeError: Incompatible merge dtype, <StringDtype(na_value=nan)> and <StringDtype(na_value=nan)>, both sides must have numeric dtype
Calling: compute
- dataframe_ids=[150, 151], code="df = df_151[df_151['period_type'] == 'quarterly'].copy()\ndf['total_revenue'] = pd.to_numeric(df['total_revenue'])\ndf = df.sort_values('date')\ndf['ttm_revenue'] = df.groupby('ticker')['total_revenue'].rolling(window=4).sum().reset_index(0, drop=True)\n\n# Merge with price\n# Ensure date columns are datetime objects for merge_asof\ndf_150['date'] = pd.to_datetime(df_150['date'])\ndf['date'] = pd.to_datetime(df['date'])\n\nmerged = pd.merge_asof(df_150.sort_values('date'), df[['date', 'ttm_revenue']].sort_values('date'), on='date', direction='backward')\nresult = merged"
DataFrame 152
OK result_152 (1256 rows)
Calling: show_chart
- dataframe_id=152, title="Salesforce (CRM) Price vs. TTM Revenue (Indexed)", series=["close", "ttm_revenue"], normalize=true
Blob 69
DataFrame 152
OK result_152 (1256 rows)
The chart below displays the Salesforce (CRM) stock price and its Trailing Twelve Month (TTM) revenue over the last 5 years, both normalized to an index of 100 for direct comparison.
The TTM revenue is calculated by taking the sum of the most recent four quarters of revenue for every trading day. Because the scale of the stock price and revenue differ significantly, the index allows you to observe how both metrics have evolved relative to each other over time.
Salesforce (CRM) Price vs. TTM Revenue (Indexed)
you dont normalise it - ill noramlise it in the chart. You should show only the raw vaalues.
Calling: show_chart
- series=["close", "ttm_revenue"], dataframe_id=152, normalize=false, title="Salesforce (CRM) Price vs. TTM Revenue (Raw Values)"
Blob 70
DataFrame 152
OK result_152 (1256 rows)