-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Dataframe): save dataframe yml (#1443)
* feat(dataframe): save dataframe to path * feat(dataframe): save dataframe to path
- Loading branch information
1 parent
43e2265
commit 0162eae
Showing
3 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import re | ||
import unicodedata | ||
|
||
|
||
def create_slug(text: str) -> str: | ||
""" | ||
Generate a slug from a given text. | ||
Args: | ||
text (str): The input text to convert into a slug. | ||
Returns: | ||
str: A URL-friendly slug. | ||
""" | ||
# Normalize text to remove accents and special characters | ||
text = unicodedata.normalize("NFKD", text) | ||
text = text.encode("ascii", "ignore").decode("ascii") | ||
|
||
# Convert to lowercase | ||
text = text.lower() | ||
|
||
# Replace spaces and unwanted characters with a hyphen | ||
text = re.sub(r"[^\w\s-]", "", text) | ||
text = re.sub(r"[\s_]+", "-", text.strip()) | ||
|
||
# Remove leading or trailing hyphens | ||
return text.strip("-") |