.data
class: Data
- class Data(**kwargs)[source]
- The - dataproperty provides a simplified interface for adding data to a chart from sources like CVS, HTML tables, or grid views. See also the tutorial article on the Data module.- Warning - It requires the - modules/data.jsfile to be loaded in the browser / client.- Warning - Please note that the default way of adding data in Highcharts, without the need of a module, is through the - series.dataproperty.- Class Inheritance - copy(other=None, overwrite=True, **kwargs)
- Copy the configuration settings from this instance to the - otherinstance.- Parameters:
- other ( - HighchartsMeta) – The target instance to which the properties of this instance should be copied. If- None, will create a new instance and populate it with properties copied from- self. Defaults to- None.
- overwrite ( - bool) – if- True, properties in- otherthat are already set will be overwritten by their counterparts in- self. Defaults to- True.
- kwargs – Additional keyword arguments. Some special descendents of - HighchartsMetamay have special implementations of this method which rely on additional keyword arguments.
 
- Returns:
- A mutated version of - otherwith new property values
 
 - classmethod from_dict(as_dict: dict, allow_snake_case: bool = True)
- Construct an instance of the class from a - dictobject.
 - classmethod from_js_literal(as_str_or_file, allow_snake_case: bool = True, _break_loop_on_failure: bool = False)
- Return a Python object representation of a Highcharts JavaScript object literal. - Parameters:
- as_str_or_file ( - str) – The JavaScript object literal, represented either as a- stror as a filename which contains the JS object literal.
- allow_snake_case ( - bool) – If- True, interprets- snake_casekeys as equivalent to- camelCasekeys. Defaults to- True.
- _break_loop_on_failure ( - bool) – If- True, will break any looping operations in the event of a failure. Otherwise, will attempt to repair the failure. Defaults to- False.
 
- Returns:
- A Python object representation of the Highcharts JavaScript object literal. 
- Return type:
- HighchartsMeta
 
 - classmethod from_json(as_json_or_file, allow_snake_case: bool = True)
- Construct an instance of the class from a JSON string. - Parameters:
- as_json_or_file – The JSON string for the object or the filename of a file that contains the JSON string. 
- allow_snake_case ( - bool) – If- True, interprets- snake_casekeys as equivalent to- camelCasekeys. Defaults to- True.
 
- Returns:
- A Python objcet representation of - as_json.
- Return type:
- HighchartsMeta
 
 - classmethod from_pandas(as_df, represent_as='csv', data_kwargs=None, pandas_kwargs=None)[source]
- Create a - Datainstance from a Pandas- DataFrame <pandas:DataFrame.- Parameters:
- as_df ( - DataFrame) – The- DataFramefrom which to create the- Datainstance.
- represent_as ( - str) – The format to which- as_dfshould be serialized. Accepts- 'csv'or- 'html'. Defaults to- 'csv'.
- data_kwargs ( - dict) – Additional keyword arguments to pass to the- Dataconstructor (- __init__()) method. Defaults to- None.
- pandas_kwargs ( - dict) – Keyword arguments to pass to the Pandas- DataFrame.to_csv()or- DataFrame.to_html()methods. Defaults to- None.
 
 - Note - To prevent unexpected behavior, if - represent_asis set to- 'csv', the- Data.table()property will be set to- None. If- represent_asis set to- 'html', the- Data.csv()property will be set to- None.- Returns:
- A - Datainstance.
 
 - classmethod from_pyspark(as_df, data_kwargs=None, pyspark_kwargs=None, consolidation='repartition')[source]
- Create a - Datainstance from a PySpark- DataFrame.- Warning - If you are using PySpark, you might be working with extremely large datasets (proverbial “big data”). Are you sure you want to be visualizing datasets of such size? If so, you should be aware that Highcharts for Python tries to store the dataset in the Python environment’s memory - not on disk. - If you need to read large datasets from disk, using the - Data.from_pyspark()is not recommended for this reason.- Parameters:
- as_df ( - pyspark.sql.DataFrame) – The- DataFramefrom which to create the- Datainstance.
- data_kwargs ( - dict) –- Additional keyword arguments to pass to the - Dataconstructor (- __init__()) method. Defaults to- None.- Warning - The - Data.csv()and- Data.table()properties will be overwritten by Highcharts for Python if specified, so don’t bother.
- pyspark_kwargs ( - dict) –- Keyword arguments to pass to the Pyspark - DataFrame.write().csv()method. Defaults to- None.- Warning - The - pathand- modearguments will be overwritten by Highcharts for Python if specified, so don’t bother.
- consolidation – - If - 'repartition', will repartition your PySpark- DataFrameinto a single unpartitioned table prior to the generation of a CSV dataset. If- 'coalesce', will coalesce your PySpark- DataFrameinto a single unpartitioned table prior to the generation of a CSV dataset. If- None, will not apply any consolidation to the- DataFrame. Defaults to- 'coalesce'.- Hint - Setting this value to - 'coalesce'is particularly useful if you are working on your- DataFramein multiple Spark nodes to prevent loss of data.- Setting this value to - Nonemay provide a boost to performance, however use with caution as it may lead to unexpected data loss or errors if using multiple Spark nodes.
 
- Returns:
- A - Datainstance.
 
 - to_dict() dict
- Generate a - dictrepresentation of the object compatible with the Highcharts JavaScript library.- Note - The - dictrepresentation has a property structure and naming convention that is intentionally consistent with the Highcharts JavaScript library. This is not Pythonic, but it makes managing the interplay between the two languages much, much simpler.
 - to_js_literal(filename=None, encoding='utf-8') str | None
- Return the object represented as a - strcontaining the JavaScript object literal.
 - to_json(filename=None, encoding='utf-8')
- Generate a JSON string/byte string representation of the object compatible with the Highcharts JavaScript library. - Note - This method will either return a standard - stror a- bytesobject depending on the JSON serialization library you are using. For example, if your environment has orjson, the result will be a- bytesrepresentation of the string.- Parameters:
- Returns:
- A JSON representation of the object compatible with the Highcharts library. 
- Return type:
 
 - static trim_dict(untrimmed: dict, to_json: bool = False) dict
- Remove keys from - untrimmedwhose values are- Noneand convert values that have- .to_dict()methods.
 - static trim_iterable(untrimmed, to_json=False)
- Convert any - EnforcedNullTypevalues in- untrimmedto- 'null'.
 - property before_parse: CallbackFunction | None
- A JavaScript callback function that is used to modify the CSV data before it is parsed. The function should return a modified version of the CSV string. Defaults to - None.- Return type:
- CallbackFunctionor- None
 
 - property columns: List[List[int | str | float | Decimal | None | EnforcedNullType]] | None
- The data itself represented in a tabular form. Expects an iterable of iterables, where each second-level iterable represents a column of data. Defaults to - None.- my_data = Data() my_data.columns = [ [None, 'Apples', 'Pears', 'Oranges'], # categories ['Ola', 1, 4, 3], # first series for "Ola" ['Kari', 5, 4, 2] # second series for "Kari" ] - Note - Each cell in the second-level iterable can either be a - str, numeric value,- None, or- EnforcedNullType.- Hint - Provided that - Data.switch_rows_and_columns()is not set, the columns will be interpreted as series.
 - property columns_url
- A URL to a remote JSON dataset, structured as a column array. Defaults to - None.- Note - Will be fetched when the chart is created using Ajax. 
 - property complete: CallbackFunction | None
- The JavaScript callback function that is evaluated when the data has finished loading (optionally from an external source) and been parsed. The first argument passed is a finished chart options object, containing the series. These options can be extended with additional options and passed directly to the chart constructor. Defaults to - None.- Return type:
- CallbackFunctionor- None
 
 - property csv: str | None
- A comma-delimited string to be parsed. Defaults to - None.- See also - The object has closely-related properties that determine which part of the CSV string should be used when constructing the chart and to configure how the CSV string should be parsed. In particular, please review: - Warning - The built-in CSV parser does not support all flavours of CSV, so in some cases it may be necessary to use an external CSV parser. See this example of parsing a CSV through the MIT-licensed Papa Parse library. 
 - property csv_url
- A URL to a remote CSV dataset. Defaults to - None.- Note - Will be fetched when the chart is created using Ajax. 
 - property data_refresh_rate: int | float | Decimal | None
- The number of seconds between each poll of data from a remote source configured using either - Data.columns_url(),- Data.csv_url(),- Data.rows_url(), or- Data.google_spreadsheet_key(). Defaults to- 1.- Warning - Cannot be set to less than - 1.- Note - For polling to be enabled, - Data.enable_polling()must be- True.- Return type:
- numeric or - None
 
 - property date_format: str | None
- Indicates the format string to use to parse date values. If - None, defaults to a best-guess based on what format gives valid and ordered dates. Defaults to- None.- Valid options include: - 'YYYY/mm/dd'
- 'dd/mm/YYYY'
- 'mm/dd/YYYY'
- 'dd/mm/YY'
- 'mm/dd/YY'
 
 - property decimal_point: str | None
- The decimal point used when parsing number values. Defaults to - '.'if- None.- Note - If both - decimal_pointand- Data.delimiter()are set to- None, the parser will attempt to deduce the decimal point automatically.- Return type:
 
 - property enable_polling: bool | None
- If - True, automatically re-fetches remote datasets every n seconds (as per- Data.data_refresh_rate()). Defaults to- False.- Note - This flag only has an impact if remote datasets are in use, as specified by any one of: 
 - property end_column: int | None
- In tabular input data, the last column (indexed by - 0) to use. If- None, defaults to the last column that contains data.
 - property end_row: int | None
- In tabular input data, the last row (indexed by - 0) to use. If- None, defaults to the last row that contains data.
 - property first_row_as_names: bool | None
- If - True, use the first row of data as series names. Defaults to- True.
 - property google_api_key: str | None
- The Google Spreadsheet API key required for access. Defaults to - None.- Note - Be sure to generate your Google Spreadsheet API key at Google’s API Services / Credentials. - Warning - To load data from Google Sheets, the - Data.google_spreadsheet_key()must be set, and must have access to the spreadsheet indicated by the spreadsheet key.
 - property google_spreadsheet_key: str | None
- The key or - spreadsheetIdvalue for the Google Sheets spreadsheet from which you wish to load data. Defaults to- None.- Hint - If you need help finding your spreadsheet key, please review the Google Sheets API Overview - Warning - To load data from Google Sheets, the - Data.google_api_key()must be set, and must have access to the spreadsheet indicated by the spreadsheet key.
 - property google_spreadsheet_range: str | None
- The Google Sheets A1 or R1C1 notation cell range from which to retrieve data. Defaults to - None.- Note - If set, this property takes precedence over - Data.start_column(),- Data.end_column(),- Data.start_row(), and- Data.end_row().- Hint - For more details on how to determine and provide the spreadsheet range, please review the relevant Google Sheets API documentation. - Warning - To load data from Google Sheets, the - Data.google_api_key()and- Data.google_spreadsheet_key()must both be set.
 - property item_delimiter: bool | str | None
- Item or cell delimiter used when parsing CSV data. If - Noneor- False, defaults to the tab character `` `` if a tab character is found in the CSV string. If no tab character is found, defaults to- ','.
 - property line_delimiter: str | None
- The string used to delimit records (lines) when parsing CSV data. Defaults to - None, which assumes- '\n'.
 - property parse_date: CallbackFunction | None
- A JavaScript callback function to parse string representations of dates into JavaScript timestamps. Should return an integer timestamp on success. Defaults to - None.- Return type:
- CallbackFunctionor- None
 
 - property parsed: CallbackFunction | None
- A JavaScript callback function to access the parsed columns (the two-dimentional input data array) directly before they are interpreted into series data and categories. The function should return - falseto stop completion, or call (in JavaScript)- this.complete()to continue asynchronously. Defaults to- None.- Return type:
- CallbackFunctionor- None
 
 - property rows: List[List[int | str | float | Decimal | None | EnforcedNullType]] | None
- The data itself represented in a tabular form. Expects an iterable of iterables, where each second-level iterable represents a row of data. Defaults to - None.- my_data = Data() my_data.rows = [ [None, 'Apples', 'Pears', 'Oranges'], # categories ['Ola', 1, 4, 3], # first series for "Ola" ['Kari', 5, 4, 2] # second series for "Kari" ] - Note - Each cell in the second-level iterable can either be a - str, numeric value,- None, or- EnforcedNullType.- Hint - Provided that - Data.switch_rows_and_columns()is not set, the rows will be interpreted as series.
 - property rows_url
- A URL to a remote JSON dataset, structured as a row array. Defaults to - None.- Note - Will be fetched when the chart is created using Ajax. 
 - property series_mapping: dict[str, int] | None
- A dictionary used to indicate where point properties are to be found in the data. Property names are the keys, while the values are the column indices indicating where in the CSV the data for that point is to be found. Defaults to - None.
 - property start_column: int | None
- In tabular input data, the first column (indexed by - 0) to use. If- None, defaults to- 0.
 - property start_row: int | None
- In tabular input data, the first row (indexed by - 0) to use. If- None, defaults to- 0.
 - property switch_rows_and_columns: bool | None
- If - True, swiches the interpretation of columns and rows so that- Data.columns()effectively becomes rows of the data while- Data.rows()is interpreted as the series of data. Defaults to- False.
 - property table: str | None
- An HTML table (in - strform), or the ID of such a table found in the browser DOM, which should be parsed to extract the data intended for visualization. Defaults to- None.- See also - The object has closely-related properties that determine which part of the HTML table should be used when constructing the chart and to configure how the table string should be parsed. In particular, please review: