Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Readability issues
Post: Readability issues

What's the best way to separate out a line of code that runs past the right margin? For example: """#practicepython.org exercise #12: Write a program that takes a list of numbers (for example,...
Mark17 General Coding Help 1 418 Nov-22-2023, 07:57 PM
    Thread: Prime number detector
Post: RE: Prime number detector

(Nov-21-2023, 08:19 PM)deanhystad Wrote: Did you read the documentation before using round? I did not... just assumed rounding was "normal," mathematical rounding. I guess anytime things don't work...
Mark17 General Coding Help 5 813 Nov-22-2023, 06:28 PM
    Thread: Prime number detector
Post: Prime number detector

This is not printing what I expect so hopefully someone can point out what I'm not understanding. for i in range(2,101): #prime number detector for j in range(2, 1 + int(round(i/2, 0))): ...
Mark17 General Coding Help 5 813 Nov-21-2023, 07:41 PM
    Thread: Why does newly-formed dict only consist of last row of each year?
Post: RE: Why does newly-formed dict only consist of las...

(Nov-17-2023, 04:54 AM)deanhystad Wrote: I was thinking of something like this: from random import randint, choice import pandas as pd # Make up some data for processing baby_names = pd.DataFrame( ...
Mark17 General Coding Help 6 799 Nov-17-2023, 05:28 PM
    Thread: Why does newly-formed dict only consist of last row of each year?
Post: RE: Why does newly-formed dict only consist of las...

(Nov-15-2023, 08:21 PM)Mark17 Wrote: (Nov-13-2023, 09:31 PM)deanhystad Wrote: What are you trying to do, count baby names by year? You could group your dataframe by (groupby) year and baby name a...
Mark17 General Coding Help 6 799 Nov-16-2023, 07:07 PM
    Thread: Why does newly-formed dict only consist of last row of each year?
Post: RE: Why does newly-formed dict only consist of las...

(Nov-13-2023, 09:31 PM)deanhystad Wrote: What are you trying to do, count baby names by year? You could group your dataframe by (groupby) year and baby name and count the number of babies in each g...
Mark17 General Coding Help 6 799 Nov-15-2023, 08:21 PM
    Thread: Why does newly-formed dict only consist of last row of each year?
Post: Why does newly-formed dict only consist of last ro...

Hi all, I'm trying to convert two columns ('BIRTH_YEAR', 'NAME') of baby_names into a dictionary. Why does the newly-formed dictionary only consist of the last df row of each year? baby_name_dict =...
Mark17 General Coding Help 6 799 Nov-13-2023, 08:10 PM
    Thread: What exactly does .agg() do?
Post: RE: What exactly does .agg() do?

(Nov-07-2023, 04:04 PM)noisefloor Wrote: The agg() method performs aggregation on the columns (or rows, but by default columns) of a dataframe. See Pandas documentation for details. Simple example:...
Mark17 Data Science 5 1,086 Nov-07-2023, 06:33 PM
    Thread: What exactly does .agg() do?
Post: What exactly does .agg() do?

Hi all, I'm not appreciating the functionality of the .agg() method. This creates a df: import pandas as pd name = ['Bella', 'Charlie', 'Lucy', 'Cooper', 'Max', 'Stella', 'Bernie'] breed = ['Labra...
Mark17 Data Science 5 1,086 Nov-07-2023, 02:26 PM
    Thread: Navigating file directories and paths inside Jupyter Notebook
Post: RE: Navigating file directories and paths inside J...

(Oct-28-2023, 09:01 PM)snippsat Wrote: When cd in cell it work as it dos in command line. Also can have no comments or other stuff,or will get SyntaxError. Got it. Thanks!
Mark17 General Coding Help 5 718 Oct-29-2023, 12:40 PM
    Thread: Navigating file directories and paths inside Jupyter Notebook
Post: RE: Navigating file directories and paths inside J...

That helps. Why does this work... cd Desktop\Desktop Transfer Material\Miscellaneous\Python...whereas this... cd Desktop\Desktop Transfer Material\Miscellaneous\Python #no backslash before first ...
Mark17 General Coding Help 5 718 Oct-28-2023, 07:23 PM
    Thread: Navigating file directories and paths inside Jupyter Notebook
Post: Navigating file directories and paths inside Jupyt...

Hi all, I want to become fluent with entering code in JN to successfully navigate my directories. For example, I want to import a .csv file like this: import pandas as pd cereal = pd.read_csv('cere...
Mark17 General Coding Help 5 718 Oct-28-2023, 01:25 PM
    Thread: What a difference print() makes
Post: What a difference print() makes

Hi all, list1 = ["cat", "dog", "cat", "dog"] list1.index("cat") list1.count("dog")If I enter that in a Jupyter Notebook cell then the output is: 2 list1 = ["cat", "dog", "cat", "dog"] print(list1.i...
Mark17 General Coding Help 2 570 Oct-19-2023, 06:49 PM
    Thread: Confusion over an Except branch
Post: Confusion over an Except branch

Hi all, Here's some code: #Create Custom Exceptions class InvalidTitle(Exception): pass try: title = input("Type the title: ") if title.isnumeric(): raise InvalidTitle("The titl...
Mark17 General Coding Help 1 422 Oct-13-2023, 06:17 PM
    Thread: __name__ and __main__ in functions
Post: __name__ and __main__ in functions

Here's a short program: lwords = ["a", "an", "and", "as", "at", "but", "for", "how", "if", "in", "of", "off", "nor", "or", "so", "the", "to", "up", "via", "with", "yet"] def make_title(sT): rlist...
Mark17 General Coding Help 3 746 Oct-11-2023, 06:09 PM
    Thread: What data types can I use for default values?
Post: What data types can I use for default values?

I'm working my way through _Teach Yourself Visually Python_ (2022). This example was presented: def parlay(odds1, odds2, odds3 = None, odds4 = None, odds5 = None): ...Following the example, a Tip is ...
Mark17 General Coding Help 1 538 Oct-09-2023, 01:50 PM
    Thread: Alphabetical or ASCII?
Post: RE: Alphabetical or ASCII?

(Oct-06-2023, 05:06 PM)deanhystad Wrote: Are you sure you copied the example correctly? Your code has a big hole in the logic. Maybe that was the purpose of the example, to identify the hole? This...
Mark17 General Coding Help 6 875 Oct-06-2023, 06:39 PM
    Thread: Alphabetical or ASCII?
Post: RE: Alphabetical or ASCII?

(Oct-05-2023, 08:48 PM)deanhystad Wrote: This logic is wrong: if x.isalnum(): if x.isalpha(): r = "alphabetical" if x.isnumeric(): r = "numeric"A str can be alphanumeric and ...
Mark17 General Coding Help 6 875 Oct-06-2023, 01:27 PM
    Thread: Alphabetical or ASCII?
Post: RE: Alphabetical or ASCII?

(Oct-05-2023, 08:41 PM)Larz60+ Wrote: x will always be a string. you can convert to whatever is needed. Example: orig = input("enter a float") print(f"orig: {orig}, type orig: {type(orig)}") afloat ...
Mark17 General Coding Help 6 875 Oct-06-2023, 12:43 PM
    Thread: Alphabetical or ASCII?
Post: Alphabetical or ASCII?

Here's a program from an intro book: x = input("Enter some input for identification: ") if x.isalnum(): if x.isalpha(): r = "alphabetical" if x.isnumeric(): r = "numeric" elif...
Mark17 General Coding Help 6 875 Oct-05-2023, 07:50 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020