Conflict
Source¶
Bases: Enum
What to do when a file to write or a column to add already exists.
Used by the to_* methods of a Table and by NewColumn.
Added in version 0.1.0
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon", "Paris"])
prices = ndp.Array.from_list([120.0, 80.0, 150.0])
sales = ndp.Table.from_arrays({"city": cities, "price": prices})
taxed_prices = sales.column("price") * 1.2
sales.add_column(ndp.NewColumn(name="price", values=taxed_prices, on_conflict=ndp.Conflict.REPLACE))
# city price
# TEXT FLOAT64
# 0 Paris 144.0
# 1 Lyon 96.0
# 2 Paris 180.0
Attributes¶
ERROR = auto()
Source¶
Raise an error and change nothing. Default value.
Added in version 0.1.0
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon", "Paris"])
prices = ndp.Array.from_list([120.0, 80.0, 150.0])
sales = ndp.Table.from_arrays({"city": cities, "price": prices})
taxed_prices = sales.column("price") * 1.2
try:
sales.add_column(ndp.NewColumn(name="price", values=taxed_prices, on_conflict=ndp.Conflict.ERROR))
except ndp.DuplicateColumnError as error:
print(error)
# The column name 'price' appears more than once.
REPLACE = auto()
Source¶
Replace the existing file or column.
Added in version 0.1.0
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon", "Paris"])
prices = ndp.Array.from_list([120.0, 80.0, 150.0])
sales = ndp.Table.from_arrays({"city": cities, "price": prices})
taxed_prices = sales.column("price") * 1.2
sales.add_column(ndp.NewColumn(name="price", values=taxed_prices, on_conflict=ndp.Conflict.REPLACE))
# city price
# TEXT FLOAT64
# 0 Paris 144.0
# 1 Lyon 96.0
# 2 Paris 180.0