You could just .split it:

>>> Path('logs/date.log.txt').stem.split('.')[0]
'date'

os.path works just as well:

>>> os.path.basename('logs/date.log.txt').split('.')[0]
'date'

It passes all of the tests:

In [11]: all(Path(k).stem.split('.')[0] == v for k, v in {
   ....:     'a': 'a',
   ....:     'a.txt': 'a',
   ....:     'archive.tar.gz': 'archive',
   ....:     'directory/file': 'file',
   ....:     'd.x.y.z/f.a.b.c': 'f',
   ....:     'logs/date.log.txt': 'date'
   ....: }.items())
Out[11]: True
Answer from Blender on Stack Overflow
🌐
Python
docs.python.org › 3 › library › pathlib.html
pathlib — Object-oriented filesystem paths
>>> p = PurePath('/usr/bin/python3') >>> p.parts ('/', 'usr', 'bin', 'python3') >>> p = PureWindowsPath('c:/Program Files/PSF') >>> p.parts ('c:\\', 'Program Files', 'PSF') (note how the drive and local root are regrouped in a single part) The parent, name, stem, and suffix properties describe different parts of a path.
🌐
Matplotlib
matplotlib.org › stable › api › _as_gen › matplotlib.pyplot.stem.html
matplotlib.pyplot.stem — Matplotlib 3.11.2 documentation
A stem plot draws lines perpendicular to a baseline at each location locs from the baseline to heads, and places a marker there. For vertical stem plots (the default), the locs are x positions, and the heads are y values.
🌐
PyPI
pypi.org › project › stem
stem
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
GeeksforGeeks
geeksforgeeks.org › python › matplotlib-pyplot-stem-in-python
Matplotlib.pyplot.stem() in Python - GeeksforGeeks
July 12, 2025 - A Stem plot plots vertical lines at each x position covered under the graph from the baseline to y, and places a marker there.
🌐
PYTHON CHARTS
python-charts.com › home › ranking › stem plot (lollipop chart) in matplotlib
Stem plot (lollipop chart) in matplotlib | PYTHON CHARTS
August 20, 2022 - The matplotlib stem function allows creating stem plots, also known as lollipop charts, in Python.
🌐
Pythontic
pythontic.com › visualization › charts › stem plot
Stem plot using Python and Matplotlib | Pythontic.com
A stem plot separates the digits in data points to form two columns. Python Matplotlib draws a stem plot as a set of Y values plotted against common X-axis values.
Find elsewhere
🌐
Udemy
udemy.com › development
Python STEM Essentials
February 1, 2023 - This course is an introduction to useful python functionality in scientific research and engineering applications that is rarely taught rigorously in universities. It begins with an overview of required numerical libraries, such as NumPy and ...
Rating: 4.7 ​ - ​ 125 votes
🌐
GeeksforGeeks
geeksforgeeks.org › python › stem-and-leaf-plots-in-python
Stem and Leaf Plots in Python - GeeksforGeeks
January 30, 2026 - Each value is split into a stem (all but the last digit) and a leaf (the last digit).
🌐
Arch Linux
archlinux.org › packages › extra › any › python-stem
Arch Linux - python-stem 1.8.3-4 (any)
View the file list for python-stem · View the soname list for python-stem · Copyright © 2002-2026 Judd Vinet, Aaron Griffin and Levente Polyák. The Arch Linux name and logo are recognized trademarks. Some rights reserved.
🌐
Matplotlib
matplotlib.org › stable › gallery › lines_bars_and_markers › stem_plot.html
Stem plot — Matplotlib 3.11.2 documentation
import matplotlib.pyplot as plt import numpy as np x = np.linspace(0.1, 2 * np.pi, 41) y = np.exp(np.sin(x)) plt.stem(x, y) plt.show()
🌐
GeeksforGeeks
geeksforgeeks.org › machine learning › python-stemming-words-with-nltk
Python | Stemming words with NLTK - GeeksforGeeks
July 11, 2025 - A stemming algorithm reduces the words “chocolates”, “chocolatey”, and “choco” to the root word, “chocolate” and “retrieval”, “retrieved”, “retrieves” reduce to the stem “retrieve”.
🌐
DataCamp
datacamp.com › tutorial › stemming-lemmatization-python
Stemming and Lemmatization in Python | DataCamp
June 1, 2026 - This tutorial covers stemming and lemmatization from a practical standpoint using the Python Natural Language ToolKit (NLTK) package.
🌐
PyPI
pypi.org › project › stemgraphic
stemgraphic · PyPI
John Tukey’s stem-and-leaf plot first appeared in 1970. Although quite useful back then, it cannot handle more than 300 data points and is completely text-based. Stemgraphic is an easy to use python package providing a solution to these limitations (no size limit, graphical tool).
      » pip install stemgraphic
    
Published: Mar 20, 2021
Version: 0.9.1
🌐
IEEE Xplore
ieeexplore.ieee.org › document › 9388001
STEM and STEAM Technologies in Problem Solving with Python | IEEE Conference Publication | IEEE Xplore
The article deals with the structure and methods of construction of the course "Problem Solving with Python" using STEM and STEAM technologies. The course is built on the principle of "visualization and problem solving head first". The techniques are offered to make the course easy to understand, including operations with NumPy arrays and slices, libraries of the Python ecosystem, domain-specific languages.
Author: OpenChemistry
🌐
GitHub
github.com › faroit › stempeg
GitHub - faroit/stempeg: Python I/O for STEM audio files · GitHub
Technically, stems are audio containers that combine multiple audio streams and metadata in a single audio file. This makes it ideal to playback multitrack audio, where users can select the audio sub-stream during playback (e.g.
Author: faroit
🌐
Readthedocs
pyrolite.readthedocs.io › en › develop › examples › plotting › stem.html
Stem Plots — pyrolite 0.3.8.dev8+g424552e92 documentation
ax = df.pyroplot.stem( orientation="vertical", s=12, linestyle="--", linewidth=0.5, color="k", figsize=(3, 5), ) # the yaxes can then be inverted using: ax.invert_yaxis() # and if you'd like the xaxis to be labeled at the top: ax.xaxis.set_ticks_position("top") ax.xaxis.set_label_position("top")