Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Python Style and Naming Variables
Post: Python Style and Naming Variables

Please consider the following Python code: def my_sum(array): ret = 0 for i in range(len(array)): ret += array[i] return ret array = [ 1,2,3,4] print( "sum is " + str(my_sum(array...
rsherry8 General Coding Help 3 2,226 Jun-07-2021, 09:00 PM
    Thread: Adding a new column to a Panda Data Frame
Post: Adding a new column to a Panda Data Frame

Please consider the following Python code: import pandas as pd data = { "l1": [50, 100, 150, 200, 250, -350, 450], "l2": [100, 120, 150, 190, 240, 200, 500], } #load data into a DataFrame objec...
rsherry8 Data Science 2 2,133 Jun-05-2021, 12:30 PM
    Thread: Error checking and a call to read_cvs
Post: RE: Error checking and a call to read_cvs

I updated the code based upon what you suggested. However, I am still not getting the line number of the bad input line in the error message. (May-08-2021, 04:16 PM)Larz60+ Wrote: Quote:I tired what...
rsherry8 Data Science 4 2,364 May-08-2021, 08:33 PM
    Thread: Error checking and a call to read_cvs
Post: RE: Error checking and a call to read_cvs

I tired what you suggested and it did not matter. The variables path1 and path2 hold the correct values. The file is being opened correctly. The file is missing a comma. The program should and is pro...
rsherry8 Data Science 4 2,364 May-08-2021, 01:09 AM
    Thread: Error checking and a call to read_cvs
Post: Error checking and a call to read_cvs

Please consider the following function: import pandas as pd def read_input(path1, path2): """Concat two paths/strs; yields pandas.DataFrame of indicated file.""" full_input_path = Path(path1...
rsherry8 Data Science 4 2,364 May-07-2021, 07:20 PM
    Thread: What does and do
Post: RE: What does and do

When I execute the following statement: type( 3 and 4 )It says the expression is int. (Apr-28-2021, 11:53 AM)Yoriz Wrote: and True if both the operands are true. print(0 and 0) print(0 and 1) prin...
rsherry8 General Coding Help 3 2,059 Apr-28-2021, 11:59 AM
    Thread: What does and do
Post: What does and do

Please consider the following Python expression where a and b have integer values. a and b I claim that value of this expression is 0, if a is 0. If a is non-zero then the value of this expressi...
rsherry8 General Coding Help 3 2,059 Apr-28-2021, 11:25 AM
    Thread: Using a Proxy Server
Post: RE: Using a Proxy Server

snippsat, Thanks for the response and your code does work for me. What I am wondering is, how long do these proxy servers stay up? Do I need to change the proxy server every day? Bob
rsherry8 Web Scraping & Web Development 12 24,917 Jul-15-2020, 03:54 PM
    Thread: Using a Proxy Server
Post: Using a Proxy Server

Please consider the following python program. import requests url = 'https://washingtonpost.com/' proxy = { "https": "https://202.29.237.212:3128", "http": "http://202.29.237.212:31...
rsherry8 Web Scraping & Web Development 12 24,917 Jul-15-2020, 01:11 PM
    Thread: Class and Operators in Python
Post: Class and Operators in Python

Please consider the following Python code fragment: import math class Fraction: def __init__(self,num,den): if den < 0: num = -num den = -den gcd =...
rsherry8 General Coding Help 1 1,997 May-27-2020, 06:53 PM
    Thread: Help with Sorting
Post: RE: Help with Sorting

j.crater and buran, Thanks for the response. Your solution works and you taught me something but is there a way to specify the comparison function that sort function uses. For example, if I wanted al...
rsherry8 General Coding Help 6 3,948 Jan-28-2018, 05:38 PM
    Thread: Help with Sorting
Post: RE: Help with Sorting

Thank you for the response. However, your code sorts based upon the number, not the absolute value of the number. Is there a way for me to pass a comparison function to the sort (or sorted) in Python?...
rsherry8 General Coding Help 6 3,948 Jan-28-2018, 04:44 PM
    Thread: Help with Sorting
Post: Help with Sorting

I am trying to understand how to sort an array in Python 3.x using the bulit in sort function. So I wrote the following code. However, it did does not work. a = [1,-2,3,-4,5,-6] sorted(a, cmp...
rsherry8 General Coding Help 6 3,948 Jan-28-2018, 03:36 PM

User Panel Messages

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