mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat(plugin-chart-echarts): support non-timeseries x-axis (#17917)
* feat(plugin-chart-echarts): support non-timeseries x-axis * fix tests * change formula return type from Date to number * add x_axis test coverage * rename func and improve coverage * add x-axis control to bar chart * remove redundant console.log * fix description * make x-axis control mandatory * 🙃 * fix x-axis formatter * fix showValues * fix implicit rDTTM_ALIAS references in postProcessing * replace TIME_COLUMN with DTTM_ALIAS * fix remaining implicit indexes * fix: Disable filtering on wide result sets (#18021) * fix: handle null values in time-series table (#18039) * cleanup column_type_mappings (#17569) Signed-off-by: Đặng Minh Dũng <dungdm93@live.com> * important change to MakeFile (#18037) * add missing is_timeseries to pivot op Co-authored-by: Erik Ritter <erik.ritter@airbnb.com> Co-authored-by: Grace Guo <grace.guo@airbnb.com> Co-authored-by: Đặng Minh Dũng <dungdm93@live.com> Co-authored-by: AAfghahi <48933336+AAfghahi@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# pylint: disable=too-many-lines
|
||||
import logging
|
||||
from decimal import Decimal
|
||||
from functools import partial
|
||||
@@ -785,6 +786,7 @@ def prophet( # pylint: disable=too-many-arguments
|
||||
yearly_seasonality: Optional[Union[bool, int]] = None,
|
||||
weekly_seasonality: Optional[Union[bool, int]] = None,
|
||||
daily_seasonality: Optional[Union[bool, int]] = None,
|
||||
index: Optional[str] = None,
|
||||
) -> DataFrame:
|
||||
"""
|
||||
Add forecasts to each series in a timeseries dataframe, along with confidence
|
||||
@@ -808,8 +810,10 @@ def prophet( # pylint: disable=too-many-arguments
|
||||
:param daily_seasonality: Should daily seasonality be applied.
|
||||
An integer value will specify Fourier order of seasonality, `None` will
|
||||
automatically detect seasonality.
|
||||
:param index: the name of the column containing the x-axis data
|
||||
:return: DataFrame with contributions, with temporal column at beginning if present
|
||||
"""
|
||||
index = index or DTTM_ALIAS
|
||||
# validate inputs
|
||||
if not time_grain:
|
||||
raise QueryObjectValidationError(_("Time grain missing"))
|
||||
@@ -826,15 +830,15 @@ def prophet( # pylint: disable=too-many-arguments
|
||||
raise QueryObjectValidationError(
|
||||
_("Confidence interval must be between 0 and 1 (exclusive)")
|
||||
)
|
||||
if DTTM_ALIAS not in df.columns:
|
||||
if index not in df.columns:
|
||||
raise QueryObjectValidationError(_("DataFrame must include temporal column"))
|
||||
if len(df.columns) < 2:
|
||||
raise QueryObjectValidationError(_("DataFrame include at least one series"))
|
||||
|
||||
target_df = DataFrame()
|
||||
for column in [column for column in df.columns if column != DTTM_ALIAS]:
|
||||
for column in [column for column in df.columns if column != index]:
|
||||
fit_df = _prophet_fit_and_predict(
|
||||
df=df[[DTTM_ALIAS, column]].rename(columns={DTTM_ALIAS: "ds", column: "y"}),
|
||||
df=df[[index, column]].rename(columns={index: "ds", column: "y"}),
|
||||
confidence_interval=confidence_interval,
|
||||
yearly_seasonality=_prophet_parse_seasonality(yearly_seasonality),
|
||||
weekly_seasonality=_prophet_parse_seasonality(weekly_seasonality),
|
||||
@@ -855,7 +859,7 @@ def prophet( # pylint: disable=too-many-arguments
|
||||
for new_column in new_columns:
|
||||
target_df = target_df.assign(**{new_column: fit_df[new_column]})
|
||||
target_df.reset_index(level=0, inplace=True)
|
||||
return target_df.rename(columns={"ds": DTTM_ALIAS})
|
||||
return target_df.rename(columns={"ds": index})
|
||||
|
||||
|
||||
def boxplot(
|
||||
|
||||
Reference in New Issue
Block a user