Python | Панды Series.to_latex ()
Серия Pandas - это одномерный массив ndarray с метками осей. Этикетки не обязательно должны быть уникальными, но должны быть хешируемого типа. Объект поддерживает индексирование как на основе целых чисел, так и на основе меток и предоставляет множество методов для выполнения операций, связанных с индексом.
Pandas Series.to_latex() function render an object to a LaTeX tabular environment table.
Syntax: Series.to_latex(buf=None, columns=None, col_space=None, header=True, index=True, na_rep=’NaN’, formatters=None, float_format=None, sparsify=None, index_names=True, bold_rows=False, column_format=None, longtable=None, escape=None, encoding=None, decimal=’.’, multicolumn=None, multicolumn_format=None, multirow=None)
Parameter :
buf : Buffer to write to. If None, the output is returned as a string.
columns : The subset of columns to write. Writes all columns by default.
col_space : The minimum width of each column.
header : Write out the column names. If a list of strings is given, it is assumed to be aliases for the column names.
index : Write row names (index)
na_rep : Missing data representation.
formatters : Formatter functions to apply to columns’ elements by position or name.
float_format : Format string for floating point numbers.
sparsify : Set to False for a DataFrame with a hierarchical index to print every multi-index key at each row.Returns : If buf is None, returns the resulting LateX format as a string, otherwise, returns None.
Example #1: Use Series.to_latex() function to render the given series object to LaTeX tabular enviornment table.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(["New York", "Chicago", "Toronto", "Lisbon", "Rio", "Moscow"]) # Create the Datetime Indexdidx = pd.DatetimeIndex(start ="2014-08-01 10:00", freq ="W", periods = 6, tz = "Europe/Berlin") # set the indexsr.index = didx # Print the seriesprint(sr) |
Выход :

Now we will use Series.to_latex() function to render the given series object to LaTeX tabular enviornment table.
# render to LaTeX tabular enviornment table.sr.to_latex() |
Выход :

As we can see in the output, the Series.to_latex() function has successfully rendered the given series object to LaTeX tabular enviornment table.
Example #2: Use Series.to_latex() function to render the given series object to LaTeX tabular enviornment table.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series([19.5, 16.8, 22.78, 20.124, 18.1002]) # Print the seriesprint(sr) |
Выход :

Now we will use Series.to_latex() function to render the given series object to LaTeX tabular enviornment table.
# render to LaTeX tabular enviornment table.sr.to_latex() |
Выход :

As we can see in the output, the Series.to_latex() function has successfully rendered the given series object to LaTeX tabular enviornment table.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.