-
Anonymous
Поляры – нет атрибута «extract_many»
Сообщение
Anonymous »
Пробую это в Polars 0.20.23, но возникает ошибка.
Код: Выделить всё
import polars as pl
# Sample data
data = {
"text": [
"Year: 2020, Month: January",
"Year: 2021, Month: February",
"Year: 2022, Month: March",
"Year: 2023, Month: April"
]
}
# Create a Polars DataFrame
df = pl.DataFrame(data)
# Define a regular expression pattern to extract year and month
pattern = r"Year: (\d{4}), Month: (\w+)"
# Use extract_many to extract year and month
df_extracted = df.with_columns(
pl.col("text").str.extract_many(pattern).alias("year_month")
)
# Display the DataFrame with extracted values
print(df_extracted)
ошибка
Код: Выделить всё
AttributeError: 'ExprStringNameSpace' object has no attribute 'extract_many'
Что я делаю не так?
Подробнее здесь:
https://stackoverflow.com/questions/796 ... tract-many
1761949234
Anonymous
Пробую это в Polars 0.20.23, но возникает ошибка.
[code]import polars as pl
# Sample data
data = {
"text": [
"Year: 2020, Month: January",
"Year: 2021, Month: February",
"Year: 2022, Month: March",
"Year: 2023, Month: April"
]
}
# Create a Polars DataFrame
df = pl.DataFrame(data)
# Define a regular expression pattern to extract year and month
pattern = r"Year: (\d{4}), Month: (\w+)"
# Use extract_many to extract year and month
df_extracted = df.with_columns(
pl.col("text").str.extract_many(pattern).alias("year_month")
)
# Display the DataFrame with extracted values
print(df_extracted)
[/code]
ошибка
[code]AttributeError: 'ExprStringNameSpace' object has no attribute 'extract_many'
[/code]
Что я делаю не так?
Подробнее здесь: [url]https://stackoverflow.com/questions/79609474/polars-no-attribute-extract-many[/url]