Feeds

The Drop Times: A Look into Drupal Association Day One Meme Submissions

Planet Drupal - Tue, 2022-12-06 06:03
Day one of '10 days of Drupal 10' , Drupal association give away is almost over and before the winners are revealed by the association, we have put out a few submissions of the meme and visual contest for you to have a look at! Do watch out for day two of the Drupal 10 Drupal Association giveaways
Categories: FLOSS Project Planets

Annertech: Drupal 10: This is what we’re so excited about

Planet Drupal - Tue, 2022-12-06 05:42

In this blog we answer some of your Drupal 10 questions, and also tell you what new features we are looking forward to the most.

Categories: FLOSS Project Planets

The Drop Times: ‘Everyday I’m Drupaling’ Music Video to Falling in Love with Drupal 10 Theming

Planet Drupal - Tue, 2022-12-06 05:35
If you have already made up your mind about a Drupal 10 feature you look forward you are a step ahead, but if not here are videos that dive into D10 feature favorites among Drupal Speakers. They may be yours too!
Categories: FLOSS Project Planets

Django Weblog: Django bugfix release: 4.1.4

Planet Python - Tue, 2022-12-06 04:32

Today we've issued the 4.1.4 bugfix release.

The release package and checksums are available from our downloads page, as well as from the Python Package Index. The PGP key ID used for this release is Carlton Gibson: E17DF5C82B4F9D00.

Categories: FLOSS Project Planets

The Drop Times: 4 Videos to Get Accustomed to Drupal 10 Before Launch

Planet Drupal - Tue, 2022-12-06 03:32
Drupal 10 to be released this month and hence the Drupal community is finding ways to celebrate. If you are still looking into what Drupal 10 is and how you can prepare before the launch, here are a few talks, Keynotes and session to watch.
Categories: FLOSS Project Planets

Python Bytes: #313 Programming Robots With a Marker

Planet Python - Tue, 2022-12-06 03:00
<a href='https://www.youtube.com/watch?v=d-JoGzArMHg' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <a href="http://pythonbytes.fm/foundershub2022"><strong>Microsoft for Startups Founders Hub</strong></a>.</p> <p><strong>Connect with the hosts</strong></p> <ul> <li>Michael: <a href="https://fosstodon.org/@mkennedy"><strong>@mkennedy@fosstodon.org</strong></a></li> <li>Brian: <a href="https://fosstodon.org/@brianokken"><strong>@brianokken@fosstodon.org</strong></a></li> <li>Special guest: <a href="https://twitter.com/KellyPared"><strong>Kelly Schuster-Paredes</strong></a></li> <li>Special guest: <a href="https://twitter.com/smtibor"><strong>Sean Tibor</strong></a></li> </ul> <p><strong>Michael #1:</strong> <strong>How do you say that number?</strong></p> <ul> <li>Inflect: <a href="https://fosstodon.org/@linuxgal@techhub.social/109430499504962727"><strong>fosstodon.org/@linuxgal@techhub.social/109430499504962727</strong></a></li> <li><p>Num2Words: <a href="https://pypi.org/project/num2words/"><strong>pypi.org/project/num2words/</strong></a></p> <pre><code># Inflect: import inflect inflector=inflect.engine() print(inflector.number_to_words(8675309)) # eight million, six hundred and seventy-five thousand, three hundred and nine # Num2Words from num2words import num2words print(num2words(8675309)) # eight million, six hundred and seventy-five thousand, three hundred and nine </code></pre></li> <li><p>Num2Words also has a CLI:</p></li> <li><code>pipx install num2words</code></li> <li><code>$ num2words 2948475</code></li> <li><code>two million, nine hundred and forty-eight thousand, four hundred and seventy-five</code></li> </ul> <p><strong>Brian #2:</strong> <a href="https://inference-review.com/article/the-origins-of-python"><strong>The Origins of Python</strong></a></p> <ul> <li>Lambert Meertens</li> <li>A wonderful tale starting with TELCOMP, traveling through ABC, and finally reaching Python. </li> <li>This is a long article, but a wonderful story.</li> <li>It includes a nice emphasis at all times to keep a language simple enough for the absolute beginner but powerful enough to not be annoying for experienced developers.</li> <li>A few quotes from the article: <ul> <li>“Ease of learning and ease of use are both desirable attributes in any programming language. Nonetheless, I have often felt that this aspect of language design does not always receive the attention it deserves. And what may seem easy to a designer may not necessarily be easy for a language learner.”</li> <li>Regarding ABC: “To serve our intended users, absolute beginners, we sought to hide low-level implementation details and instead to provide powerful high-level, task-oriented features.</li> <li>Then Python: “The growth in popularity of Python, from its inception thirty years ago as a one-person effort flying under the radar, has been phenomenal, but not meteoric. Instead it has been a long, slow, and steady rise. Python’s ease of learning gave it a competitive advantage in a period when there was a perpetual need for more programmers. Its clean syntax and semantics make it easier to maintain a software base written in Python than other languages—an important consideration given that the cost of maintaining software dwarfs the cost of creating new software.”</li> </ul></li> </ul> <p><strong>Kelly</strong> <strong>#3:</strong> </p> <ul> <li><a href="https://shop.ozobot.com/cart">Ozobot Evo</a> Introduces a Python Beta Version. (<a href="https://ozobot.com/2022/08/17/"><strong>August 17, 2022</strong></a>)</li> <li>The original Ozobot model – the Ozobot Bit – is no longer available for purchase . The New Evo Ozobit- has three Kit options. The Entry Kit (single robot), the Ozobot Evo 12-Pack, and the Ozobot Evo 18-Pack. </li> <li>https://beta.python.ozobot.com/doc-python-api/ozobot.html#module-0 </li> <li>Still has the updated OzoBlockly platform for Block Programming.</li> <li>This tiny bot comes with: <ul> <li>Line following</li> <li>Color detection</li> <li>Sound</li> <li>proximity sensor</li> <li>bluetooth</li> <li>Crash detection</li> <li>Students can even code functions</li> </ul></li> <li>Ozobot simulator(block) https://games.ozoblockly.com/shapetracer-freeform</li> <li>Web beta app: <a href="https://beta.python.ozobot.com">beta.python.ozobot.com</a></li> </ul> <p><strong>Michael #4:</strong> <a href="https://pypi.org/project/setproctitle/"><strong>setproctitle</strong></a></p> <ul> <li><p>A Python module to customize the process title</p></li> <li><p>Awesome for servers and anytime “python” is not enough</p></li> <li><p>Easy to use directly:</p></li> <li><p>from setproctitle import setproctitle</p></li> <li><p>setproctitle("tp-search daemon")</p></li> <li><p>Used automatically by servers like uwsgi and gunicorn I believe.</p> <pre><code>### # uWSGI server configuration ### [uwsgi] # uWSGI provides some functionality which can help identify the workers procname-prefix = training- auto-procname = true </code></pre></li> <li><p>Some nice results, example from Talk Python Training <img src="https://python-bytes-static.nyc3.digitaloceanspaces.com/server-with-names.png" alt="" /></p></li> </ul> <p><strong>Brian #5:</strong> <strong>Looking forward to Python 3.12</strong></p> <ul> <li><a href="https://www.python.org/downloads/release/python-3120a2/">New features in 3.12a2</a> <ul> <li>Improved Error Messages</li> <li>lots of other goodies, like <code>pathlib.walk()</code>.</li> </ul></li> <li><a href="https://peps.python.org/pep-0693/">Release scheduled for Oct 2023</a></li> <li>But why wait? Start testing your projects with it now: <a href="http://localhost:1313/testing-with-python-3.12">Te</a><a href="https://pythontest.com/testing-with-python-3-12">sting with Python 3.12</a></li> <li>Note that “During the alpha phase, features may be added up until the start of the beta phase (2023-05-08) and, if necessary, may be modified or deleted up until the release candidate phase (2023-07-31). Please keep in mind that this is a preview release and its use is not recommended for production environments.”</li> <li>Actually, with that note, you might want to wait. I don’t. I’ll deal with it when/if I get a failure. </li> </ul> <p><strong>Sean</strong> <strong>#6:</strong> <a href="https://www.youtube.com/watch?v=rRBLl7MsZVU&amp;list=PL2yQDdvlhXf9F-GUSSZ2jBtelyiWRFHNV&amp;index=13"><strong>Re:Invent 2022 EF Education Breakout</strong></a></p> <ul> <li>Presentation at AWS Re:Invent 2022</li> <li>Complete redesign of online learning platform by one of the largest education companies in the world</li> <li>We’ve all seen Zoom classrooms with rows on rows of students</li> <li>A more immersive experience for learning with green screens, digital sets, and props</li> <li>Massive amount of analytics around student engagement and learning, including full transcription of every student, engagement tracking, and computer vision</li> <li> <img src="https://paper-attachments.dropboxusercontent.com/s_8972A8B4AFB195FA45E7A043E2BDE6670DA22712B4D99F7D7829C7C10300934F_1670335403294_image.png" alt="" /></li> </ul> <p><strong>Extras</strong> </p> <p>Michael:</p> <ul> <li>You can support the PSF if you’re selling things on EBay. Check “Donate a portion to charity” and choose “Python Software Foundation” via Joe Riedley</li> <li><a href="https://learn.microsoft.com/en-us/windows/powertoys/text-extractor">Textinator for Windows</a> (the Windows version of <a href="https://www.textsniper.app">TextSniper</a>)</li> <li><a href="https://paperlike.com">Paperlike</a> for iPad</li> </ul> <p>Kelly: A new Special Interest Group for the PSF launched 6 days ago. “Edu-sig, through its <a href="http://www.python.org/mailman/listinfo/edu-sig">mailing list</a>, provides an informal venue for comparing notes and discussing future possibilities for Python in education.” Led by Timothy Wilson.</p> <p>Sean:</p> <ul> <li><a href="https://www.youtube.com/watch?v=RfvL_423a-I">Dr. Werner Vogel’s keynote</a> - everything is coming up async</li> <li><a href="https://aws.amazon.com/eventbridge/pipes/">EventBridge Pipes</a></li> </ul> <p><strong>Jokes:</strong> </p> <p><a href="https://fosstodon.org/@kimvanwyk/109389398652030679">fosstodon.org/@kimvanwyk/109389398652030679</a></p> <p>And a new mastodon user:</p> <p><a href="https://fosstodon.org/@vruz@mastodon.social/109394538570819699">fosstodon.org/@vruz@mastodon.social/109394538570819699</a></p> <p><img src="https://imgs.xkcd.com/comics/feature_comparison.png" alt="Feature Comparison" /></p>
Categories: FLOSS Project Planets

Specbee: Starterkit Theme in Drupal 10: Implementing a Better Starting Point for your Theme

Planet Drupal - Tue, 2022-12-06 01:53
Starterkit Theme in Drupal 10: Implementing a Better Starting Point for your Theme Ashutosh Ahirwal 06 Dec, 2022 Subscribe to our Newsletter Now Subscribe Leave this field blank

Frontend developers and themers have some exciting news coming up with the release of Drupal 10. The new starterkit theme is almost here! Although it has been available for testing since Drupal 9.5.

Starting with the basics, let's talk about themes. Themes are basically the foundation of the entire layout and design of your Drupal website. It is the layer of the website which is seen by end users and it comprises design components like color palettes, font, headers, footers, and other aesthetics of the site.

Now, sub-theming has been a core part of Drupal for a very long time. Sub-theming is the process of inheriting a parent theme’s resources. Creating a sub-theme in Drupal has generally been a manual process by typically inheriting from a core theme (Classy) or any contributed theme to use readily available markup and styling. Drupal Starter kit will completely change the perspective of sub-theming for developers. Read on to find out how and also learn to implement the new Starterkit theme.

Why use the Starterkit Theme

Drupal has been providing the ability to subtheme for a while now. But recently we all have noticed that the Classy theme has not been receiving any updates since Drupal 8.0.0 because it needs to maintain backward compatibility and any changes made might break it. 

When you sub-theme a core theme, it uses the common markup and CSS of the parent theme. And if your Drupal site is dependent on a base theme like Classy, you will not have very few options to make any changes because Classy needs to retain backward compatibility. For that reason, the new concept of a Starterkit theme has been introduced in Drupal 10 core.

Features of the New Starterkit

Drupal has introduced Starterkit in branch 10.0.x and the version is 10.0.0-beta1. It has replaced Classy which is now a contributed project.

  1. As the name suggests, Starterkit will act as a starting point to generate themes. It does not need to be extended as a base theme but rather copied onto the new theme.
  2. Drupal will provide frequent updates on the default markup and CSS in core so that these features will help Front-end developers.
  3. Sub-theming will still be an existing option to create subthemes. This is important in cases where themes are inheriting some common CSS and markup from the base Drupal theme.
  4. If a theme is already using the classy theme, it can continue doing so with the contributed classy theme, which will be the same as using the core Classy theme.
  5. You can generate a new theme using the command line interface tool.
Generating a new theme using CLI

Run this command in the respective (Drupal, docroot, web) folder to create a theme inside the theme folder.

php core/scripts/drupal generate-theme my_new_theme

Add your theme name in place of my_new_theme.

Example: 

php core/scripts/drupal generate-theme test

On running this command, the theme is generated outside of the custom folder.

 

So to generate themes inside the custom folder, you will need to add the path of the file folder like so:

php core/scripts/drupal generate-theme test --path themes/custom

The output will look like this:

 

To see all configuration options, you can reference the help:

php core/scripts/drupal generate-theme --help Customizing the Starterkit

Starterkit tools provide the freedom to use a contributed or custom theme as the parent theme. For this, you need to add source_theme_name in the command line (which can you get from --help) and then add starterkit: true; in the theme in which you want as create a starter theme or sub-theme. (Remove starterkit: true; after generating the theme)

So finally, the command will look like this:

php core/scripts/drupal generate-theme my_new_them --path [path_of_file_folder] --starterkit source_theme_name 

Example:

php core/scripts/drupal generate-theme demotheme --path theme/custom --starterkit bartik

And the theme will look like this:

 

This theme is generated using Bartik theme and can be checked in the info.yml file of the theme

You can change the generated theme name, code, files, etc according to the requirements.

Tracking upstream changes

When the theme is generated, you need to check for any upcoming changes in the Starterkit core, especially about features, bug fixes, etc. This is also important when you are using starterkit as your base theme

  • Check the version of the core Starterkit theme

When you have generated a theme from Drupal core you need to check the version of the starterkit. You can check for it in the info.yml file in the generator key.

generator: starterkit_theme:9.3.0

With this you can now compare the version of the theme using Git or Drupal core repository.

Syntax

git diff

Example: 

git diff 9.3.0 9.4.0 core/themes/classy/
  • Check the list of theme changes by issue

If you find too many issues then you can review the changes from the list. Check the list of issues by using the below command:

Syntax

git log

Example: 

git log 9.4.0 9.3.0 core/themes/classy/ Final Thoughts

There’s so much to look forward to in Drupal 10 with the Starterkit being a significant enhancement, especially for frontend developers. Enhancements and problem-solvers like the Starterkit proves that Drupal is a truly continuously evolving CMS and is on the right path to making it easier to adopt. As a purely Drupal development company, you can trust our experts to implement Drupal in the best way possible for your next project. We’d love to talk!

Author: Ashutosh Ahirwal

Meet Ashutosh Ahirwal, a Drupal Front-end Developer who is a big-time foodie and a travel enthusiast. Ashutosh is a night owl who fancies going on a long bike ride to Leh-Ladakh, admiring the nature around. He strongly believes there is no such thing as “too much cheese” :)

Drupal Development Drupal 10 Drupal Planet

Leave us a Comment

  Recent Blogs Image Starterkit Theme in Drupal 10: Implementing a Better Starting Point for your Theme Image Things you need for a Drupal 8 to Drupal 9 Upgrade - A Checklist Image Getting Started with Layout Builder in Drupal 9 - A Complete Guide Want to extract the maximum out of Drupal? TALK TO US Featured Success Stories

Upgrading and consolidating multiple web properties to offer a coherent digital experience for Physicians Insurance

Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology

Great Southern Homes, one of the fastest growing home builders in the United States, sees greater results with Drupal 9

View all Case Studies
Categories: FLOSS Project Planets

Read the Docs: Read the Docs newsletter - December 2022

Planet Python - Mon, 2022-12-05 19:00

This newsletter contains the first features and updates that have hatched since we announced a Q4 focus on core platform features in the previous newsletter.

News and updates

Here are the latest updates from our team:

You can always see the latest changes to our platforms in our Read the Docs Changelog.

Upcoming features
  • We’re working on improving our integration with Material for MkDocs, which is a great theme for MkDocs documentation projects.

  • Many improvements to our URL handling code, which will allow us to support more flexible URL configurations for projects.

  • A search redesign to make it nicer across our dashboard and in-doc search experiences.

  • 404 pages are being improved by contextualization the user message, giving relevant guidance to readers and project owners.

Possible issues

Sphinx 6 is coming very soon. For those of you planning to upgrade immediately, we are preparing a blog post with a couple of considerations in that regard.

If you find regressions in any new releases of the sphinx-rtd-theme, please don’t hesitate to open an issue on GitHub.

Our Q4 focus also includes deprecating old and outdated approaches to using our platform. We don’t have anything firm to announce here yet, but we do plan to be more active in removing these features in the coming months.

Tip of the month

Do you need to document past or upcoming events? Chris Sewell has created sphinx-timeline for exactly this.

See sphinx-timeline in full action on the main page of AiiDA (which by the way is built with Read the Docs).

Awesome Project of the month

Nautobot is a great example of a documentation landing page with several subprojects. See all the highlights in the following Twitter thread:

Nautobot is the project of our today’s 💫 Showcase the Docs 🌟 edition!

“An extensible and flexible Network Source of Truth and Network Automation Platform that is the cornerstone of any network automation architecture” #Nautobot #documentation pic.twitter.com/icp2q2Epty

— Read the Docs (@readthedocs) November 22, 2022 Awesome Read the Docs Projects List 🕶️

Looking for more inspiration? Check out our new list: Awesome Read the Docs Projects.

Considering using Read the Docs for your next documentation project? Check out our documentation to get started!

Questions? Comments? Ideas for the next newsletter? Contact us!

Categories: FLOSS Project Planets

GNUnet News: GNUnet 0.19.0

GNU Planet! - Mon, 2022-12-05 18:00
GNUnet 0.19.0 released

We are pleased to announce the release of GNUnet 0.19.0.
GNUnet is an alternative network stack for building secure, decentralized and privacy-preserving distributed applications. Our goal is to replace the old insecure Internet protocol stack. Starting from an application for secure publication of files, it has grown to include all kinds of basic protocol components and applications towards the creation of a GNU internet.

This is a new major release. It breaks protocol compatibility with the 0.18.x versions. Please be aware that Git master is thus henceforth (and has been for a while) INCOMPATIBLE with the 0.18.x GNUnet network, and interactions between old and new peers will result in issues. 0.18.x peers will be able to communicate with Git master or 0.19.x peers, but some services will not be compatible.
In terms of usability, users should be aware that there are still a number of known open issues in particular with respect to ease of use, but also some critical privacy issues especially for mobile users. Also, the nascent network is tiny and thus unlikely to provide good anonymity or extensive amounts of interesting information. As a result, the 0.19.0 release is still only suitable for early adopters with some reasonable pain tolerance .

Download links

The GPG key used to sign is: 3D11063C10F98D14BD24D1470B0998EF86F59B6A

Note that due to mirror synchronization, not all links might be functional early after the release. For direct access try http://ftp.gnu.org/gnu/gnunet/

Noteworthy changes in 0.19.0 (since 0.18.2)
  • UTIL : Moved GNUNET_BIO_MetaData handling into FS .
  • BUILD : platform.h removed as it should not be used by third parties anyway. gnunet_config.h is renamed to gnunet_private_config.h and the new replacement gnunet_config.h is added to provide build information for components linking against/using GNUnet.
  • UTIL : Components part of gnunet_util_lib.h must now be included through gnunet_util_lib.h and through that header only .
  • NAMESTORE : gnunet-namestore can now parse a list of records into zones from stdin in new recordline format.
  • GTK : Added an identity selector to the search to accomodate for previously deprecated "default" identities for subsystems.
  • Other: Postgres plugins implementations modernized and previous regressions fixed.

A detailed list of changes can be found in the ChangeLog and the bug tracker .

Known Issues
  • There are known major design issues in the TRANSPORT, ATS and CORE subsystems which will need to be addressed in the future to achieve acceptable usability, performance and security.
  • There are known moderate implementation limitations in CADET that negatively impact performance.
  • There are known moderate design issues in FS that also impact usability and performance.
  • There are minor implementation limitations in SET that create unnecessary attack surface for availability.
  • The RPS subsystem remains experimental.
  • Some high-level tests in the test-suite fail non-deterministically due to the low-level TRANSPORT issues.

In addition to this list, you may also want to consult our bug tracker at bugs.gnunet.org which lists about 190 more specific issues.

Thanks

This release was the work of many people. The following people contributed code and were thus easily identified: Christian Grothoff, Tristan Schwieren, madmurphy, t3sserakt, TheJackiMonster and Martin Schanzenbach.

Categories: FLOSS Project Planets

Talking Drupal: Talking Drupal #376 - Burnout

Planet Drupal - Mon, 2022-12-05 14:00

Today we are talking about Burnout with Jono Bacon.

For show notes visit: www.talkingDrupal.com/376

Topics
  • What is burnout
  • Why is it so important to you
  • Have you suffered from burnout
  • Do different professions have different rates of burnout
  • Is it individual or teams / projects / community oriented
  • Is it only mental or can it be physical
  • What contributes to burnout as a contributor or maintainer
  • What can prevent burnout
  • How do you recover
  • First episode was Talking Drupal #265
  • Helping communities
  • Signs to watch out for
  • What is next
Resources Guests

Jono Bacon - www.jonobacon.com @jonobacon

Hosts

Nic Laflin - www.nLighteneddevelopment.com @nicxvan John Picozzi - www.epam.com @johnpicozzi Leslie Glynn - @leslieglynn

MOTW Correspondent

Martin Anderson-Clutz - @mandclu Token The Token module provides a centralized API for text substitution. Since Drupal 7 some Token support is built into core, but the module provides common and reusable token UI elements and missing core tokens.

Categories: FLOSS Project Planets

SystemSeed.com: Upgrade to Drupal 9 before Drupal 7 goes end-of-life

Planet Drupal - Mon, 2022-12-05 12:59
Upgrade to Drupal 9 before Drupal 7 goes end-of-life

If your websites still use Drupal 7, you should be planning to upgrade to Drupal 9 as the end of life for Drupal 7 is drawing near

Lilian Ochieng Mon, 12/05/2022 - 17:59
Categories: FLOSS Project Planets

Real Python: Python News: What's New From November 2022

Planet Python - Mon, 2022-12-05 09:00

The Python world never stops spinning! After the release of Python 3.11 in October, the Python release team is already launching the first alpha versions of Python 3.12. The excitement of trying shiny new things shouldn’t distract you from being cautious while coding, though. Recently, researchers found more malicious packages on PyPI, and lawyers raised concerns about license violations when using GitHub Copilot to generate code.

Let’s dive into the biggest Python news from the past month!

Join Now: Click here to join the Real Python Newsletter and you'll never miss another Python tutorial, course update, or post.

Python 3.12 Alpha Released

One of the most newsworthy events from October was the release of Python 3.11. While many of us are exploring the cool new features of Python 3.11, others are already hard at work on the next release.

Right on track with the Python 3.12 release schedule, the Python release team unveiled Python 3.12 alpha 2 in the middle of November. The core team is still early in the development cycle, but so far, the list of new features seems exciting.

Here’s some of what’s coming in Python 3.12:

  • Even more improved error messages
  • Support for the Linux perf profiler
  • Deprecation of old functions, classes, and modules

While Python 3.11 already improved error messages, the next feature release will offer even better suggestions for fixing errors. For example, check out what it does when you forget to import a module or order your import statements wrong:

>>>>>> sys.version_info Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'sys' is not defined. Did you forget to import 'sys'? >>> import pi from math File "<stdin>", line 1 import pi from math ^^^^^^^^^^^^^^^^^^^ SyntaxError: Did you mean to use 'from ... import ...' instead?

Especially when you’re learning Python, constructive error messages can point you in the right direction to improve your code. But also, if you’re a seasoned Python developer, then the upcoming Python release will have something in stock for your code improvements:

Read the full article at https://realpython.com/python-news-november-2022/ »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]

Categories: FLOSS Project Planets

Python for Beginners: Create Index in a Pandas Series

Planet Python - Mon, 2022-12-05 09:00

Pandas series objects are used to store data when we need to access it using its position as well as labels. In this article, we will discuss different ways to create index in a pandas series. 

Table of Contents
  1. Create Index in a Pandas Series Using the Index Parameter
  2. Create Index in a Pandas Series Using the Index Attribute
  3. Create an Index in a Pandas Series Using the set_axis() Method
    1. The set_axis() Method
  4. Create Index Inplace in a Pandas Series
  5. Conclusion
Create Index in a Pandas Series Using the Index Parameter

When we create a pandas series, it has a default index starting from 0 to the length of the series-1. For instance, consider the following example.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] series=pd.Series(letters) print("The series is:") print(series)

Output:

The series is: 0 a 1 b 2 c 3 ab 4 abc 5 abcd 6 bc 7 d dtype: object

In the above example, we have created a series of 8 elements. You can observe that the indices of the elements in the series are numbered from 0 to 7. These are the default indices.

If you want to assign a custom index to the series, you can use the index parameter in the Series() constructor. The index parameter in the Series() constructor takes a list having an equal number of elements as the elements in the series and creates a custom index for the series as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters,index=numbers) print("The series is:") print(series)

Output:

The series is: 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In the above example, we have passed the python list [3, 23, 11, 14, 16, 2, 45, 65] to the index parameter of the Series() constructor. After the execution of the Series() constructor, the elements of this list are assigned as the indices of the elements in the series.

Create Index in a Pandas Series Using the Index Attribute

You can also create a new index for a series after creating the series. For instance, if you want to assign other values as indices in the series, you can use the index attribute of the series object. To create a new custom index, you can assign a list of values to the index attribute as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters) series.index=numbers print("The series is:") print(series)

Output:

The series is: 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In this example, we have assigned the list [3, 23, 11, 14, 16, 2, 45, 65] to the index attribute of the series after creating the series. Hence, the elements of this list are assigned as the indices of the elements in the series.

Here, the list passed to the index attribute must have a length equal to the number of elements in the series. Otherwise, the program will run into a ValueError exception. You can observe this in the following example.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65,117] series=pd.Series(letters) series.index=numbers print("The series is:") print(series)

Output:

ValueError: Length mismatch: Expected axis has 8 elements, new values have 9 elements

In the above example, you can observe that the list "letters" has only 8 elements. As a result, the series contains only 8 elements. On the other hand, the list "numbers" has 9 elements. Hence, when we assign the "numbers" list to the index attribute of the series, the program runs into a ValueError exception.

Suggested Reading: If you are into machine learning, you can read this MLFlow tutorial with code examples. You might also like this article on clustering mixed data types in Python.

Create an Index in a Pandas Series Using the set_axis() Method

Instead of using the index attribute, we can use the set_axis() method to create an index in a pandas series. 

The set_axis() Method

The set_axis() method has the following syntax.

Series.set_axis(labels, *, axis=0, inplace=_NoDefault.no_default, copy=_NoDefault.no_default)

Here, 

  • The labels parameter takes a list-like object containing index values. You can also pass an Index object to the labels parameter. The number of elements in any object passed to the labels parameter should have the same number of elements as the series on which the set_axis() method is invoked.
  • The axis parameter is used to decide if we want to create the index for rows or columns. As a Series has only one column, the axis parameter is unused. 
  • After creating a new index, the set_axis() method returns a new Series object. If you want to modify the original Series object, you can set the inplace parameter to True. 
  • The copy parameter is used to decide whether to make a copy of the underlying data instead of modifying the original series. By default, it is True. 

To create an index using the set_axis() method, we will invoke this method on the original series object. We will pass a list containing the new index values to the set_axis() method as an input argument. After execution, the set_axis() method will return a new series having a modified index. You can observe this in the following example.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters) series=series.set_axis(labels=numbers) print("The series is:") print(series)

Output:

The series is: 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In this example, we have first created a series containing 8 elements. Then, we used the set_index() method to assign new indices to the elements in the series. You can observe that the set_index() method returns a new series. Hence, the original series isn’t modified. To modify the original series by assigning new indices instead of creating a new one, you can create an index in place in the series.

Create Index Inplace in a Pandas Series

To create an index inplace in a pandas series, you can assign the new index to the index attribute of the series object as shown in the following example.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters) series.index=numbers print("The series is:") print(series)

Output:

The series is: 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

You can also use the set_axis() method to create an index inplace in a series. For this, you can pass the list containing the new index values to the set_axis() method and set the inplace parameter to True while invoking the set_axis() method on the original series object. After execution, you will get the modified series object as shown below.

import pandas as pd import numpy as np letters=["a","b","c","ab","abc","abcd","bc","d"] numbers=[3,23,11,14,16,2,45,65] series=pd.Series(letters) series.set_axis(labels=numbers,inplace=True) print("The series is:") print(series)

Output:

The series is: 3 a 23 b 11 c 14 ab 16 abc 2 abcd 45 bc 65 d dtype: object

In this example, we used the set_index() method to assign new indices to the elements in the series. You can observe that we have set the inplace parameter to True in the set_index() method. Hence, the new indices are assigned in the original series object itself.

While using the inplace parameter you will get a FutureWarning stating "FutureWarning: Series.set_axis 'inplace' keyword is deprecated and will be removed in a future version. Use obj = obj.set_axis(..., copy=False) instead". It means that the inplace parameter has been deprecated. Hence, if the same code is used in future versions of pandas, the program may run into an error. To avoid this, you can use the copy parameter.

By default, the copy parameter is set to True. Hence, the set_axis() method uses a copy of the original series and modifies it. If you want to modify the original series, you can set the copy parameter to False in the set_axis() method.

Conclusion

In this article, we discussed different ways to create the index in a pandas series in Python. To know more about the pandas module, you can read this article on how to sort a pandas dataframe. You might also like this article on how to drop columns from a pandas dataframe.

The post Create Index in a Pandas Series appeared first on PythonForBeginners.com.

Categories: FLOSS Project Planets

Mike Driscoll: PyDev of the Week: Miroslav Šedivý

Planet Python - Mon, 2022-12-05 08:23

This week we welcome Miroslav Šedivý as our PyDev of the Week! Miro has been a speaker at several different Python conferences. You can also catch up with Miro on his website or by checking out Miro's GitHub Profile.

Let's take some time to get to know Miro better!

Can you tell us a little about yourself (hobbies, education, etc):

My name is Miroslav Šedivý, but most people call me Miro, which allows them to avoid typing some letters they do not have on their keyboard. I was born in Czechoslovakia (yes, I am over 30 now), studied computer sciences in France and Germany, and now I am living in Austria.

Computers and programming were the hobbies that became my occupation. Another hobby, which is difficult to combine professionally with the first one, is human languages. As a Central European fascinated by travel, I speak a bunch of languages and enjoy using them every day.

Apart from this, I love spending time with my family, hiking, biking, fixing OpenStreetMap, camping, and woodworking.

You can find me at https://mas.to/@eumiro and occasionally at some Python events.

Why did you start using Python?

After I have developed a quite complex power forecasting system for wind turbines in Perl using PDL (Perl equivalent to NumPy), my colleagues started using Python for new projects. It was around 2008, in the age of Python 2.5 with some rumors of Python 3. I got myself a book called “Perl to Python Migration” and tried to wrap my head around the new concepts.

The worst thing I remember from my beginnings was the necessity to "import re" each time I wanted to work with regular expressions. In Perl it was second nature to do almost anything with regular expressions. Not it Python. And this is beautiful about different languages: the way of thinking in them. Just like in French one does not simply count to seventy, nor in Czech say “one beer” (“one” is actually a synonym for “beer”), in Python one, can use other tools to dissect strings.

What other programming languages do you know and which is your favorite?

There were some BASIC and Pascal somewhere in the past century, but now my number one is Python, accompanied by Shell. I remember some Perl, Java, C, and PHP from more or less serious projects in the past, and I have played with Go and Rust.

The choice of language usually depends on the task. I also do not use English to speak about food and cuisine, or Polish to comment a Python code review. I am using Python only for stuff it fits well. Luckily, it fits most of the stuff I am working on.

What projects are you working on now?

Apart from my work, I have some sleeping projects at https://github.com/eumiro, which are currently waiting for another burst of enthusiasm or external input. A day has only 24±1 hours, but I wish it had more.

Which Python libraries are your favorite (core or 3rd party)?

From standard lib, I am always happy if I can reach into the itertools module and simplify my code. Migration to Python 3 brings pathlib, which is a complete game changer when working with file system. I am also happy to see some gaps closing between the different modules, so you do not have to import anything else to obtain Unix timestamp of a datetime object, for instance.

There are plenty of wonderful third-party libraries I have worked with. The most important and complex one is probably pandas.

How did you end up contributing to open source projects?

At my first Python conference EuroPython 2015 in Bilbao, I met Francesc Alted from the PyTables team and as an active user of the library I had a long discussion with him at the end, we even did a sprint and with his help, I removed one obsolete exception-raiser from the codebase that was bugging me since some time.

Later I occasionally contributed to some projects I was using, but then around Christmas 2020 I had quite a lot of free time and I discovered outdated CI/CD configurations in dozens of Python projects, so I started systematically helping them to fix the pipelines and also to modernize their code. This is where one of my talks “There Are Python 2 Relics In Your Code!” were born. Python 2 hacks like `int(math.floor(x))` work in Python 3 but they do not make sense in modern code and should be refactored.

What are the top three things you've learned as a contributor?

Make small steps. Even smaller. If you think you've done a great bunch of work and submit a huge PR, the maintainers will have a very difficult time reviewing it and any rebase in an active project will probably stop their interest in your contribution.

Maintainers are humans with jobs paying their bills. Respect their time and energy and do not expect they're here only for you.

Comment on the project. Show how you're using it in your own work to make the maintainers feel their endeavor matters.

Is there anything else you’d like to say?

Please do not use backslashes to deliberately break lines. If there's some line length limit (whether it is 78, 80, 88, 100, or 120), it makes your code more readable. There's virtually always a possibility to reformat your code to respect this limit and avoid horizontal scrolling in editor. Every such formatting allows you to break the line at a suitable position. Breaking lines with backslashes tells the reader “you have to join these lines in your head into a very long one to understand it.”

Finally, I'd like to thank Mike for his engagement and the whole Python community for collaborating on such a marvelous set of products and the whole ecosystem around it. So happy to be a part of it!

Thanks for doing the interview, Miro!

The post PyDev of the Week: Miroslav Šedivý appeared first on Mouse Vs Python.

Categories: FLOSS Project Planets

Zato Blog: LDAP and Active Directory as Python API Services

Planet Python - Mon, 2022-12-05 05:41

LDAP and Active Directory often play key a role in the management of a company’s network resources yet it is not always very convenient to query a directory directly using the LDAP syntax and protocol that few people truly specialize in. This is why in this article we are using Zato to offer a REST API on top of directory services so that API clients can use REST and JSON instead.

Installing Zato

Start off by installing Zato - if you are not sure what to choose, pick the Docker Quickstart option and this will set up a working environment in a few minutes.

Creating connections

Once Zato is running, connections can be easily created in its Dashboard (by default, http://127.0.0.1:8183). Navigate to Connections -> Outgoing -> LDAP ..

.. and then click Create a new connection which will open a form as below:

The same form works for both regular LDAP and Active Directory - in the latter case, make sure that Auth type is set to NTLM.

The most important information is:

  • User credentials
  • Authentication type
  • Server or servers to connect to

Note that if authentication type is not NTLM, user credentials can be provided using the LDAP syntax, e.g. uid=MyUser,ou=users,o=MyOrganization,dc=example,dc=com.

Right after creating a connection be sure to set its password too - the password asigned by default is a randomly generated one.

Pinging

It is always prudent to ping a newly created connection to ensure that all the information entered was correct.

Note that if you have more than one server in a pool then the first available one of them will be pinged - it is the whole pool that is pinged, not a particular part of it.

Active Directory as a REST service

As the first usage example, let’s create a service that will translate JSON queries into LDAP lookups - given username or email the service will basic information about the person’s account, such as first and last name.

Note that the conn object returned by client.get() below is capable of running any commands that its underlying Python library offers - in this case we are only using searches but any other operation can also be used, e.g. add or modify as well.

# -*- coding: utf-8 -*- # stdlib from json import loads # Bunch from bunch import bunchify # Zato from zato.server.service import Service # Where in the directory we expect to find the user search_base = 'cn=users, dc=example, dc=com' # On input, we are looking users up by either username or email search_filter = '(&(|(uid={user_info})(mail={user_info})))' # On output, we are interested in username, first name, last name and the person's email query_attributes = ['uid', 'givenName', 'sn', 'mail'] class ADService(Service): """ Looks up users in AD by their username or email. """ class SimpleIO: input_required = 'user_info' output_optional = 'message', 'username', 'first_name', 'last_name', 'email' response_elem = None skip_empty_keys = True def handle(self): # Connection name to use conn_name = 'My AD Connection' # Get a handle to the connection pool with self.out.ldap[conn_name].conn.client() as client: # Get a handle to a particular connection with client.get() as conn: # Build a filter to find a user by user_info = self.request.input['user_info'] user_filter = search_filter.format(user_info=user_info) # Returns True if query succeeds and has any information on output if conn.search(search_base, user_filter, attributes=query_attributes): # This is where the actual response can be found response = conn.entries # In this case, we expect at most one user matching input criteria entry = response[0] # Convert it to JSON for easier handling .. entry = entry.entry_to_json() # .. and load it from JSON to a Python dict entry = loads(entry) # Convert to a Bunch instance to get dot access to dictionary keys entry = bunchify(entry['attributes']) # Now, actually produce a JSON response. For simplicity's sake, # assume that users have only one of email or other attributes. self.response.payload.message = 'User found' self.response.payload.username = entry.uid[0] self.response.payload.first_name = entry.givenName[0] self.response.payload.last_name = entry.sn[0] self.response.payload.email = entry.mail[0] else: # No business response = no such user found self.response.payload.message = 'No such user'

After creating a REST channel, we can invoke the service from command line, thus confirming that we can offer the directory as a REST service:

$ curl "localhost:11223/api/get-user?user_info=MyOrganization\\MyUser" ; echo { "message": "User found", "username": "MyOrganization\\MyUser", "first_name": "First", "last_name": "Last", "email": "address@example.com" } $ Next steps
  • Start the tutorial to learn more technical details about Zato, including its architecture, installation and usage. After completing it, you will have a multi-protocol service representing a sample scenario often seen in banking systems with several applications cooperating to provide a single and consistent API to its callers.

  • Check more resources for developers and screenshots.

  • Para aprender más sobre las integraciones de Zato y API en español, haga clic aquí

Categories: FLOSS Project Planets

Salsa Digital Drupal-Related Articles: GovCMS Mega Meetup wrap up

Planet Drupal - Mon, 2022-12-05 02:59
December 2022 GovCMS Mega Meetup It was fantastic to be part of the December 2022 GovCMS Mega Meetup, the first in-person GovCMS event for 3 years. It was a great community turnout, and attendees were clearly very engaged.  John Sheridan kicked the day off by announcing a major milestone…over a billion page views hit since GovCMS was launched 2015.  Next, Sharyn Clarkson took to the stage and presented on the ‘great spike’, showing attendees stats on some of the traffic GovCMS sites had during the pandemic. She focused most of her presentation on the GovCMS Roadmap.  Two of the major points on the roadmap are: Rules as Code (RaC)  CivicTheme for GovCMS  RaC is a space we’ve actively been working in over the past year or so.  We were particularly thrilled to have CivicTheme highlighted.
Categories: FLOSS Project Planets

Podcast.__init__: Declarative Machine Learning For High Performance Deep Learning Models With Predibase

Planet Python - Sun, 2022-12-04 19:42
Deep learning is a revolutionary category of machine learning that accelerates our ability to build powerful inference models. Along with that power comes a great deal of complexity in determining what neural architectures are best suited to a given task, engineering features, scaling computation, etc. Predibase is building on the successes of the Ludwig framework for declarative deep learning and Horovod for horizontally distributing model training. In this episode CTO and co-founder of Predibase, Travis Addair, explains how they are reducing the burden of model development even further with their managed service for declarative and low-code ML and how they are integrating with the growing ecosystem of solutions for the full ML lifecycle.Preamble

This is a cross-over episode from our new show The Machine Learning Podcast, the show about going from idea to production with machine learning.

Summary

Deep learning is a revolutionary category of machine learning that accelerates our ability to build powerful inference models. Along with that power comes a great deal of complexity in determining what neural architectures are best suited to a given task, engineering features, scaling computation, etc. Predibase is building on the successes of the Ludwig framework for declarative deep learning and Horovod for horizontally distributing model training. In this episode CTO and co-founder of Predibase, Travis Addair, explains how they are reducing the burden of model development even further with their managed service for declarative and low-code ML and how they are integrating with the growing ecosystem of solutions for the full ML lifecycle.

Announcements
  • Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great!
  • When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With their managed Kubernetes platform it’s easy to get started with the next generation of deployment and scaling, powered by the battle tested Linode platform, including simple pricing, node balancers, 40Gbit networking, dedicated CPU and GPU instances, and worldwide data centers. And now you can launch a managed MySQL, Postgres, or Mongo database cluster in minutes to keep your critical data safe with automated backups and failover. Go to pythonpodcast.com/linode and get a $100 credit to try out a Kubernetes cluster of your own. And don’t forget to thank them for their continued support of this show!
  • Your host is Tobias Macey and today I’m interviewing Travis Addair about Predibase, a low-code platform for building ML models in a declarative format
Interview
  • Introduction
  • How did you get involved in machine learning?
  • Can you describe what Predibase is and the story behind it?
  • Who is your target audience and how does that focus influence your user experience and feature development priorities?
  • How would you describe the semantic differences between your chosen terminology of "declarative ML" and the "autoML" nomenclature that many projects and products have adopted?
    • Another platform that launched recently with a promise of "declarative ML" is Continual. How would you characterize your relative strengths?
  • Can you describe how the Predibase platform is implemented?
    • How have the design and goals of the product changed as you worked through the initial implementation and started working with early customers?
    • The operational aspects of the ML lifecycle are still fairly nascent. How have you thought about the boundaries for your product to avoid getting drawn into scope creep while providing a happy path to delivery?
  • Ludwig is a core element of your platform. What are the other capabilities that you are layering around and on top of it to build a differentiated product?
  • In addition to the existing interfaces for Ludwig you created a new language in the form of PQL. What was the motivation for that decision?
    • How did you approach the semantic and syntactic design of the dialect?
    • What is your vision for PQL in the space of "declarative ML" that you are working to define?
  • Can you describe the available workflows for an individual or team that is using Predibase for prototyping and validating an ML model?
    • Once a model has been deemed satisfactory, what is the path to production?
  • How are you approaching governance and sustainability of Ludwig and Horovod while balancing your reliance on them in Predibase?
  • What are some of the notable investments/improvements that you have made in Ludwig during your work of building Predibase?
  • What are the most interesting, innovative, or unexpected ways that you have seen Predibase used?
  • What are the most interesting, unexpected, or challenging lessons that you have learned while working on Predibase?
  • When is Predibase the wrong choice?
  • What do you have planned for the future of Predibase?
Contact Info Parting Question
  • From your perspective, what is the biggest barrier to adoption of machine learning today?
Closing Announcements
  • Thank you for listening! Don’t forget to check out our other shows. The Data Engineering Podcast covers the latest on modern data management. The Machine Learning Podcast helps you go from idea to production with machine learning.
  • Visit the site to subscribe to the show, sign up for the mailing list, and read the show notes.
  • If you’ve learned something or tried out a project from the show then tell us about it! Email hosts@podcastinit.com) with your story.
  • To help other people find the show please leave a review on iTunes and tell your friends and co-workers
Links

The intro and outro music is from Hitman’s Lovesong feat. Paola Graziano by The Freak Fandango Orchestra/CC BY-SA 3.0

Categories: FLOSS Project Planets

digiKam 7.9.0 is released

Planet KDE - Sun, 2022-12-04 19:00
Dear digiKam fans and users, After four months of active maintenance and another bug triage, the digiKam team is proud to present version 7.9.0 of its open source digital photo manager. See below the list of most important features coming with this release. Bundles Internal Component Updates As with the previous releases, we take care about upgrading the internal components from the Bundles. Microsoft Windows Installer, Apple macOs Package, and Linux AppImage binaries now hosts:
Categories: FLOSS Project Planets

Guest Post: OpenUK Awards 2022 Sustainability

Planet KDE - Sun, 2022-12-04 19:00

This is a guest post by Jonathan Esk-Riddell for the KDE Eco blog about the OpenUK Awards.

OpenUK is an advocacy organisation for open tech (software, hardware and data) in the UK. We run various activities and I have had the priviledge of hosting the award ceremony for the last few years.

Last year at COP26 in Glasgow I announced KDE Eco, the KDE project to measure and certify apps as energy efficient. For those reading this who aren't familiar, KDE is an open source community making apps for Linux and other platforms. KDE Eco has two parts, FOSS Energy Efficiency Project, developing tools to improve energy efficiency in free and open source software development. And Blauer Engel For FOSS, working with German Environment Agency to create eco-certification with the Blauer Engel label for desktop software.

This year our ceremony was at the House of Lords in the UK parliament. The host was Francis Maud, a member of the House of Lords who as a minister a decade ago created gov.uk, a single website for many government services with policies for open data and open formats.

At the House of Lords I gave an update on KDE Eco on St Andrews day. I was pleased to talk about how Okular, our PDF and docs reader, had become the first software product to receive the Blue Angel eco-label.

The link was because one of the awards we present at the OpenUK Awards is for sustainability.

The nominations on the shortlist for sustainability award were:

Carbon Aware SDK, Szymon Duchniewicz, an SDK to enable the creation of carbon aware applications, applications that do more when the electricity is clean and do less when the electricity is dirty, to help organisations achieve Net Zero for carbon emissions.

Devtank, a company focused on sustainability and reducing our customers carbon footprint to Net Zero using Open Source licensed solutions. We are delighted to be delivering energy management and control systems to businesses and local authorities, nationwide. If a potential customer is looking to decarbonise their business and monitor environmental performance, then our Open Smart Monitor ENV01 is the recommended product.

Fergus Kidd, Carbon CI Pipeline Tooling, provides a feasible way to measure carbon generated by cloud infrastructure as part of the software development lifecycle.

Scores from our judges were high for all of these but the final trophy went to Carbon Aware SDK by Szymon Duchniewicz. Congratulations to Szymon and all the nominees.

The OpenUK Awards 2022 at the House of Lords

The work of KDE is made possible thanks to the contributions from KDE Community members, donors and corporations that support us. Every individual counts, and every commitment, large or small, is a commitment to Free Software. Head to the KDE's End of Year fundraiser page and donate now.

Categories: FLOSS Project Planets

Brian Okken: Testing with Python 3.12

Planet Python - Sun, 2022-12-04 19:00
Python 3.12.0a2 is out. So now may be a great time to get your projects to start testing against 3.12. Note about alpha releases of Python This is from the same link as above: “During the alpha phase, features may be added up until the start of the beta phase (2023-05-08) and, if necessary, may be modified or deleted up until the release candidate phase (2023-07-31). Please keep in mind that this is a preview release and its use is not recommended for production environments.
Categories: FLOSS Project Planets

Pages