Search Results
|
Post |
Author |
Forum |
Replies |
Views |
Posted
[asc]
|
|
|
Thread: custom sqrt
Post: RE: custom sqrt
I modified
if abs(a-b) < tolerance: return bto
if abs(a-b) <= tolerance: return bWhen I run the code on my work pc, the sqrt appears as expected, for example:
[Image: https://drive.google.com/f... |
|
bluefrog |
General Coding Help |
4 |
3,053 |
Jul-14-2019, 08:12 PM |
|
|
Thread: custom sqrt
Post: custom sqrt
I am attempting to create a sqrt function using mainly recursion with the use of a lambda.
I picked the code up from a book "Functional Python Programming 2ed".
The example is shown in the 1st chapte... |
|
bluefrog |
General Coding Help |
4 |
3,053 |
Jul-12-2019, 02:51 PM |
|
|
Thread: to_numpy() works in jupyter notebook, but not in python script
Post: RE: to_numpy() works in jupyter notebook, but not ...
I have 0.23 on my Ubuntu Linux, but 0.24 on my miniconda environment.
I used sudo apt-get install in an attempt to update pandas to 0.24, but I get this message:
$ sudo apt-get install python3-panda... |
|
bluefrog |
Data Science |
7 |
10,128 |
Jun-27-2019, 10:35 AM |
|
|
Thread: to_numpy() works in jupyter notebook, but not in python script
Post: RE: to_numpy() works in jupyter notebook, but not ...
Thanks for spotting the missing comma.
The error that appears is as follows:
Traceback (most recent call last):
File "./dataframe_swap_columns.py", line 23, in <module>
df_copy.loc[:, ['B... |
|
bluefrog |
Data Science |
7 |
10,128 |
Jun-27-2019, 10:13 AM |
|
|
Thread: to_numpy() works in jupyter notebook, but not in python script
Post: to_numpy() works in jupyter notebook, but not in p...
Hi
I am unsure why the following works in a jupyter notebook, but not in a python script that I am run from the Linux command line:
#!/usr/bin/python3
import pandas as pd
import numpy as np
# SWAPP... |
|
bluefrog |
Data Science |
7 |
10,128 |
Jun-26-2019, 05:54 PM |
|
|
Thread: future warning when using numpy fancy indexing
Post: future warning when using numpy fancy indexing
After loading arrays from a data file, I get a future warning message when I try and use the result of one of the arrays as a mask over another;
this generates the same error, but uses sample data in... |
|
bluefrog |
Data Science |
0 |
4,247 |
Nov-20-2018, 09:44 AM |
|
|
Thread: numpy dtype anomaly
Post: RE: numpy dtype anomaly
thanks. it now works.
so basically one has to specify your record column names and data types each time you extract an arbitrary set of column number(s).
mmmm, bit clunky. |
|
bluefrog |
Data Science |
4 |
3,474 |
Nov-07-2018, 12:37 AM |
|
|
Thread: numpy dtype anomaly
Post: RE: numpy dtype anomaly
I've reduced the number of columns to 4, and still the error occurs if usecols is specified. If not, it succeeds in loading each column into an array. I've taken out the missing column, which is colum... |
|
bluefrog |
Data Science |
4 |
3,474 |
Nov-07-2018, 12:00 AM |
|
|
Thread: numpy dtype anomaly
Post: numpy dtype anomaly
I'm attempting to load 2 arrays from 2 columns read from a file . The file is delimited and I'm using numpy's loadtxt() function to load the arrays, like so:
#!/usr/bin/python3
import sys
import num... |
|
bluefrog |
Data Science |
4 |
3,474 |
Nov-05-2018, 09:09 PM |
|
|
Thread: pathlib hanging
Post: pathlib hanging
Its the first time I'm using pathlib. Any reference to it seems to hang. Is it something to so with permissions ?
I'm working under my home directory, so there shouldn't be an issue.
Output:bluefrog@p... |
|
bluefrog |
General Coding Help |
2 |
3,089 |
Sep-23-2018, 08:56 PM |
|
|
Thread: type hint additional message
Post: RE: type hint additional message
I've created a mypy.ini as suggested in the link you posted:
$ pwd
/home/bluefrog/anaconda3/pkgs/mypy-0.620-py37_0
$ cat > mypy.ini <<EOF
> [mypy]
> python_version = 3.7
> warn_retur... |
|
bluefrog |
Homework |
5 |
3,296 |
Sep-17-2018, 07:28 PM |
|
|
Thread: type hint additional message
Post: RE: type hint additional message
celcius_to_fahrenheit.py:8: error: Unsupported operand types for - ("None" and "int")
celcius_to_fahrenheit.py:8: note: Left operand is of type "Union[int, float, Decimal, None]"
celcius_to_fahrenheit... |
|
bluefrog |
Homework |
5 |
3,296 |
Sep-17-2018, 09:14 AM |
|
|
Thread: type hint additional message
Post: type hint additional message
I'm attempting to type hint on a temperature conversion function.
The function has a deliberate mistake in that it returns a Number instead of a dictionary, but the
return statement is for a Dictionar... |
|
bluefrog |
Homework |
5 |
3,296 |
Sep-16-2018, 09:38 PM |
|
|
Thread: Problem with for loops
Post: RE: Problem with for loops
|
bluefrog |
Homework |
4 |
3,249 |
Sep-16-2018, 09:31 PM |
|
|
Thread: write split words of sentence to file
Post: write split words of sentence to file
When I test the split on Python's IDLE, I get a list of words, for example:
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for mor... |
|
bluefrog |
Homework |
1 |
2,952 |
Aug-26-2018, 08:51 PM |
|
|
Thread: code copy from pep-3134
Post: code copy from pep-3134
I'm attempting to run the snippet of code in PEP-3134, but I'm not getting the errors stated.
The code relates to implicit exception handling. The expectation, according to the PEP, is:
Quote:The ult... |
|
bluefrog |
General Coding Help |
1 |
2,177 |
Aug-26-2018, 02:59 PM |
|
|
Thread: sorting a list of tuples based on date
Post: sorting a list of tuples based on date
Hi
I am unsure whether the tuple is sorted or not.
There appears to be no difference to the list of tuples after being sorted.
#!/usr/bin/python3
import operator
from datetime import datetime
phones... |
|
bluefrog |
General Coding Help |
2 |
5,727 |
Aug-09-2018, 09:09 PM |
|
|
Thread: python format conversion
Post: python format conversion
Hi
I'm just wondering why I cannot print the following:
#!/usr/bin/python3
some_integer = 10
some_string = "Hello World"
print("{some_integer!r} {some_string!r} ".format(some_integer, some_string))Bu... |
|
bluefrog |
Homework |
2 |
2,636 |
Jul-22-2018, 02:52 PM |
|
|
Thread: exclusive bitwise OR
Post: exclusive bitwise OR
Hi
Am using 3.6.5
I'm trying to display the result of a bitwise operation, like so:
xor = 0b0011 ^ 0b0111
print ("Example of exclusive OR - xor = 0b0011 ^ 0b0111: ".format(bin(xor)))But nothing appea... |
|
bluefrog |
Homework |
1 |
2,166 |
Jul-10-2018, 12:26 PM |
|
|
Thread: printing main doc
Post: printing main doc
I have a doc declared at the top of a script, like so:
#!/usr/bin/python3
import re
"""
A Twitter username can only contain alphanumeric characters (A-Z numbers 0-9).
The exception being an underscor... |
|
bluefrog |
General Coding Help |
1 |
2,488 |
Jun-27-2018, 11:13 AM |