MCPcopy Index your code
hub / github.com/plotly/plotly.py / to_named_series

Function to_named_series

plotly/express/_core.py:1194–1210  ·  view source on GitHub ↗

Assuming x is list-like or even an existing Series, returns a new Series named `name`.

(x, name=None, native_namespace=None)

Source from the content-addressed store, hash-verified

1192
1193
1194def to_named_series(x, name=None, native_namespace=None):
1195 """Assuming x is list-like or even an existing Series, returns a new Series named `name`."""
1196 # With `pass_through=True`, the original object will be returned if unable to convert
1197 # to a Narwhals Series.
1198 x = nw.from_native(x, series_only=True, pass_through=True)
1199 if isinstance(x, nw.Series):
1200 return x.rename(name)
1201 elif native_namespace is not None:
1202 return nw.new_series(name=name, values=x, native_namespace=native_namespace)
1203 else:
1204 try:
1205 import pandas as pd
1206
1207 return nw.new_series(name=name, values=x, native_namespace=pd)
1208 except ImportError:
1209 msg = "Pandas installation is required if no dataframe is provided."
1210 raise NotImplementedError(msg)
1211
1212
1213def process_args_into_dataframe(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected