Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I want to play around with machine learning for fun. To start with say I want to build and train a model to tell me if a picture is a (hot)dog or not a (hot)dog. How do I get started?

Adbot
ADBOT LOVES YOU

BannedNewbie
Apr 22, 2003

HOW ARE YOU? -> YOSHI?
FINE, THANK YOU. -> YOSHI.

Boris Galerkin posted:

I want to play around with machine learning for fun. To start with say I want to build and train a model to tell me if a picture is a (hot)dog or not a (hot)dog. How do I get started?

If you want to have a clue what you're doing take Andrew Ng's machine learning class on coursera, if you don't install scikit learn, read some of the docs and go nuts.

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"
Hey everyone, looking for a little help with figuring out why I can't get any of my IDE's to import "quandl" or "Quandl".

I'm running Windows 10, 64 bit OS.

I've installed a couple of other packages using this command:

"py -m pip install [name]"

I use "py -m pip list" to see what is installed. I see that I have:
C:\WINDOWS\system32>py -m pip list
Package Version
--------------- ---------
absl-py 0.3.0
astor 0.7.1
certifi 2018.4.16
chardet 3.0.4
gast 0.2.0
grpcio 1.14.1
idna 2.7
inflection 0.3.1
Markdown 2.6.11
more-itertools 4.3.0
numpy 1.14.5
pandas 0.23.4
pip 18.0
protobuf 3.6.0
python-dateutil 2.7.3
pytz 2018.5
Quandl 3.4.1
requests 2.19.1
scikit-learn 0.19.2
setuptools 28.8.0
six 1.11.0
sklearn 0.0
tensorboard 1.10.0
tensorflow 1.10.0
termcolor 1.1.0
urllib3 1.23
Werkzeug 0.14.1
wheel 0.31.1


When I go to my IDEs, I have MSV 2017, Anaconda, and regular Python 3.6.4 Shell, and attempt to import Quandl I get:


In MSV using Python 3.6 64 and 32 bit:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Quandl'

In Anaconda, using Spyder 3.2.8:

Traceback (most recent call last):

File "<ipython-input-2-9b0ae57416bb>", line 1, in <module>
import Quandl

ModuleNotFoundError: No module named 'Quandl'

In Python 3.6.4 shell:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import Quandl
ModuleNotFoundError: No module named 'Quandl'


I've uninstalled using the same command line as installing except with the command "uninstall" and then reinstalled without any issues or flags raised in my command prompt in admin, but still nothing.


The other packages (sklearn, pandas, etc.) have all installed and import just fine.

I wasn't sure if this thread or the non existent python thread in Haus of Tech Support would be better.

I've searched Google and it's the same answer over and over, pretty much just making sure the programmer has pip-installed the package correctly or showing how to pip-install using command lines that don't work on my system. (which I would also love to get some info or reading material as to why, btw). No changes to my system. I'm stationed in Japan but I'm using a computer I bought an "american" HP (just trying to provide as much info as possible in accordance with the Haus rules.)

Anyway, any help would be appreciated. Thanks!

Dominoes
Sep 20, 2007

The import's lower-case for that module, despite the uppercase module name. You said you tried it, but your examples all use upper-case. I can't see what's wrong; try import quandl again.

Mark Larson
Dec 27, 2003

Interesting...

Hollow Talk posted:

Have a look if pandas is good enough. Depending on how deep the nesting is, I usually tend to use nested dict comprehensions to flatten dictionaries when I want more control and/or need to ensure data quality in a more granular way. I find this particularly useful for large data, since it gives me more explicit control over chunking, and I can use iterators for lazy evaluation (pandas is not great when trying to parse a 90GB JSON file, for example).

Thanks for your responses. I will take a look at Airflow and Luigi once it starts getting complex enough. I'm also using Stitch so I could also change over to the Singer Tap methodology once it gets complicated enough to benefit from the Stitch backend, and integrate with their other integrations.

For the second point, could you tell me what you mean by using nested dict comprehensions to flatten dictionaries? Like a code example from Stack Overflow would be good. My searches haven't led to much. There are 3 levels of nesting I'm potentially looking at, but they are optional since I can get those attributes by calling another API.

cinci zoo sniper
Mar 15, 2013




Mark Larson posted:

Thanks for your responses. I will take a look at Airflow and Luigi once it starts getting complex enough. I'm also using Stitch so I could also change over to the Singer Tap methodology once it gets complicated enough to benefit from the Stitch backend, and integrate with their other integrations.

For the second point, could you tell me what you mean by using nested dict comprehensions to flatten dictionaries? Like a code example from Stack Overflow would be good. My searches haven't led to much. There are 3 levels of nesting I'm potentially looking at, but they are optional since I can get those attributes by calling another API.

https://www.datacamp.com/community/tutorials/python-dictionary-comprehension should be an OK start.

Hollow Talk
Feb 2, 2014

Mark Larson posted:

Thanks for your responses. I will take a look at Airflow and Luigi once it starts getting complex enough. I'm also using Stitch so I could also change over to the Singer Tap methodology once it gets complicated enough to benefit from the Stitch backend, and integrate with their other integrations.

For the second point, could you tell me what you mean by using nested dict comprehensions to flatten dictionaries? Like a code example from Stack Overflow would be good. My searches haven't led to much. There are 3 levels of nesting I'm potentially looking at, but they are optional since I can get those attributes by calling another API.


This has a few good examples. To be fair, I don't think nested dictionary comprehensions are necessarily any more readable than nested for loops. This is an example from a (really rather) quick and dirty script I needed in order to extract and subsequently flatten the contents of a SPSS file:

code:
_l = reader.varLabels
_r = iter(OrderedDict(zip(reader.header, row)) for row in reader.all())
_a = reader.valueLabels

# Replace body values with aliases
if args.join is True:
    _records = iter({k: _a.get(k).get(v) if _a.get(k) is not None else v for k, v in x.items()} for x in _r)
    records = iter([y.decode('utf-8') if isinstance(y, bytes) else y for y in x.values()] for x in _records)
elif args.join is False:
    records = iter([y.decode('utf-8') if isinstance(y, bytes) else y for y in x.values()] for x in r)
I don't necessarily recommend using this all over the place, but these are sometimes the best way to flatten nested structures, I think.

cinci zoo sniper
Mar 15, 2013




Yeah I prefer to write loops of customised “getter” functions for non-trivial JSON/XML parses, but I do calculations on them, rather than ETL stuff, so that approach lends itself to dispose of intermediaries in a lazy fashion.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!

BannedNewbie posted:

If you want to have a clue what you're doing take Andrew Ng's machine learning class on coursera, if you don't install scikit learn, read some of the docs and go nuts.

This one? Just signed up to Coursera and this course says I can either pay or do it for free. Do I lose out on anything if I do it for free other than the certificate? (Never done one of this online courses before. Are the certificates even worth anything?)

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
completion rate is somethin like 5% free 50% paid

besides that, you don't get anything, really. the cert's worth bupkis

cinci zoo sniper
Mar 15, 2013




Yeah the only point of certificates is to serve as a poor completion motivator. And yes, that is the right course and it is absolutely fantastic - one of the first recommendations I make to less experienced hires into my data science team.

Mark Larson
Dec 27, 2003

Interesting...

Boris Galerkin posted:

This one? Just signed up to Coursera and this course says I can either pay or do it for free. Do I lose out on anything if I do it for free other than the certificate? (Never done one of this online courses before. Are the certificates even worth anything?)

It gives you a sense of ~~ pride and accomplishment ~~

I finally put up for a paid subscription after trying out a bunch of courses and never getting past the 2nd week. It's working, I'm halfway through one course and 80% done with another. It's $50 a month, which if you do more than one course at a time isn't bad. By the way, you can have Coursera automatically post your certificates on LinkedIn if you use that.

You can also go through the material for free for a few months and then register for the course you want, to get the certificate if you are that hard up.

Mark Larson fucked around with this message at 10:56 on Aug 14, 2018

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Thanks guys. No certificate for me it is.

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"

Dominoes posted:

The import's lower-case for that module, despite the uppercase module name. You said you tried it, but your examples all use upper-case. I can't see what's wrong; try import quandl again.

I didn't include the error message for the lower case "quandl" because they were the same, with the exception of the physical memory location address. (i think it's the address anyway)

Still no luck.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

a forbidden love posted:

Anyway, any help would be appreciated. Thanks!
Are you running python 2 and 3 side by side? You may have installed it in 2 and not 3.

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"

Peeny Cheez posted:

Are you running python 2 and 3 side by side? You may have installed it in 2 and not 3.

Nope. Only 3. I only had the shell then I got anaconda, and nothing still, then I added the ie to msv and still nothing. Last shot would be a clean install all over again but I'm not sure how effective that would be since every other package installs and imports correctly.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Can you do a help('modules') in whichever interpreter you want to use and see if Quandl is listed?

a forbidden love posted:

I've searched Google and it's the same answer over and over, pretty much just making sure the programmer has pip-installed the package correctly or showing how to pip-install using command lines that don't work on my system. (which I would also love to get some info or reading material as to why, btw).

Which command line commands don't work for you?

Boris Galerkin fucked around with this message at 08:29 on Aug 15, 2018

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Symbolic Butt posted:

Alternatively it seems like a very turtle thing:



Perfect!

I've never even touched turtle, though I have of course heard of it for a couple decades...

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
I really want to like pipenv but I just can't because it feels like it's a buggy cryptic mess and nothing it tells me/outputs makes any sense at all.

For example I just created a new pipenv with the following Pipfile:

code:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
scipy = "*"
pandas = "*"

[dev-packages]

[requires]
python_version = "3.6"
Everything works great. Now I add jupyter and it gives me this mess of an output:

code:
Successfully installed [...] widgetsnbextension-3.4.0

Adding jupyter to Pipfile's [packages]...

Pipfile.lock (94e126) out of date, updating to (52d57c)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
Could not find a version that matches widgetsnbextension==3.3.1,~=3.3.0,~=3.4.0
Tried: [...], 3.4.0, 3.4.0
Skipped pre-versions: [...]
There are incompatible versions in the resolved dependencies.
So pipenv tells me it installed widgetsnbextension-3.4.0, and then it tells me that it can't find a compatible version of widgetsnbextension that matches either 3.3.1, 3.3.0+, or 3.4.0+. Then it also tells me that it tried to install version 3.4.0 (twice), but for some reason it doesn't think 3.4.0 matches version number 3.4.0.

It was a fun experience but back to conda environments I go.

e: Meanwhile, jupyter was successfully installed in this pipenv and it works fine. What the hell does any of this even mean.

Boris Galerkin fucked around with this message at 08:56 on Aug 16, 2018

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"

Boris Galerkin posted:

Can you do a help('modules') in whichever interpreter you want to use and see if Quandl is listed?



Of course, thanks for the assist.
code:
>>> help('quandl')
No Python documentation found for 'quandl'.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.

>>> help('modules')

Please wait a moment while I gather a list of all available modules...

C:\Users\Family\Anaconda3\lib\site-packages\IPython\kernel\__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)
WARNING: AstropyDeprecationWarning: astropy.utils.compat.futures is now deprecated - use concurrent.futures instead [astropy.utils.compat.futures]
C:\Users\Family\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
C:\Users\Family\Anaconda3\lib\site-packages\odo\backends\pandas.py:102: FutureWarning: pandas.tslib is deprecated and will be removed in a future version.
You can access NaTType as type(pandas.NaT)
  @convert.register((pd.Timestamp, pd.Timedelta), (pd.tslib.NaTType, type(None)))
C:\Users\Family\Anaconda3\lib\site-packages\nltk\twitter\__init__.py:20: UserWarning: The twython library has not been installed. Some functionality from the twitter package will not be available.
  warnings.warn("The twython library has not been installed. "
tmp3ipgaq0x.c
c1: fatal error C1083: Cannot open source file: 'C:\Users\Family\AppData\Local\Temp\tmp3ipgaq0x.c': Permission denied
C:\Users\Family\Anaconda3\lib\site-packages\qtawesome\iconic_font.py:268: UserWarning: You need to have a running QApplication to use QtAwesome!
  warnings.warn("You need to have a running "
_cffi_ext.c
lib\site-packages\zmq\backend\cffi\__pycache__\_cffi_ext.c(213): fatal error C1083: Cannot open include file: 'sys/un.h': No such file or directory
C:\Users\Family\Anaconda3\lib\pkgutil.py:107: VisibleDeprecationWarning: zmq.eventloop.minitornado is deprecated in pyzmq 14.0 and will be removed.
    Install tornado itself to use zmq with the tornado IOLoop.
    
  yield from walk_packages(path, info.name+'.', onerror)
Crypto              bz2                 mkl_random          sphinxcontrib
Cython              cProfile            mmap                spyder
IPython             calendar            mmapfile            spyder_breakpoints
OpenSSL             certifi             mmsystem            spyder_io_dcm
PIL                 cffi                modulefinder        spyder_io_hdf5
PyQt5               cgi                 more_itertools      spyder_profiler
__future__          cgitb               mpmath              spyder_pylint
_ast                chardet             msgpack             sqlalchemy
_asyncio            chunk               msilib              sqlite3
_bisect             click               msvcrt              sre_compile
_blake2             cloudpickle         multipledispatch    sre_constants
_bootlocale         clyent              multiprocessing     sre_parse
_bz2                cmath               navigator_updater   ssl
_cffi_backend       cmd                 nbconvert           sspi
_codecs             code                nbformat            sspicon
_codecs_cn          codecs              netbios             stat
_codecs_hk          codeop              netrc               statistics
_codecs_iso2022     collections         networkx            statsmodels
_codecs_jp          colorama            nltk                storemagic
_codecs_kr          colorsys            nntplib             string
_codecs_tw          commctrl            nose                stringprep
_collections        compileall          notebook            struct
_collections_abc    comtypes            nt                  subprocess
_compat_pickle      concurrent          ntpath              sunau
_compression        conda               ntsecuritycon       symbol
_csv                conda_build         nturl2path          sympy
_ctypes             conda_env           numba               sympyprinting
_ctypes_test        conda_verify        numbers             symtable
_datetime           configparser        numexpr             sys
_decimal            contextlib          numpy               sysconfig
_distutils_findvs   contextlib2         numpydoc            tables
_dummy_thread       copy                odbc                tabnanny
_elementtree        copyreg             odo                 tarfile
_functools          crypt               olefile             tblib
_hashlib            cryptography        opcode              telnetlib
_heapq              csv                 openpyxl            tempfile
_imp                ctypes              operator            terminado
_io                 curl                optparse            test
_json               curses              os                  test_path
_locale             cwp                 packaging           test_pycosat
_lsprof             cycler              pandas              testpath
_lzma               cython              pandocfilters       tests
_markupbase         cythonmagic         parser              textwrap
_md5                cytoolz             parso               this
_msi                dask                partd               threading
_multibytecodec     datashape           path                time
_multiprocessing    datetime            pathlib             timeit
_nsis               dateutil            pathlib2            timer
_opcode             dbi                 patsy               tkinter
_operator           dbm                 pdb                 tlz
_osx_support        dde                 pep8                token
_overlapped         decimal             perfmon             tokenize
_pickle             decorator           pickle              toolz
_pydecimal          difflib             pickleshare         tornado
_pyio               dis                 pickletools         trace
_pytest             distributed         pip                 traceback
_random             distutils           pipes               tracemalloc
_sha1               doctest             pkg_resources       traitlets
_sha256             docutils            pkginfo             tty
_sha3               dummy_threading     pkgutil             turtle
_sha512             easy_install        platform            turtledemo
_signal             email               plistlib            types
_sitebuiltins       encodings           pluggy              typing
_socket             ensurepip           ply                 unicodecsv
_sqlite3            entrypoints         poplib              unicodedata
_sre                enum                posixpath           unittest
_ssl                errno               pprint              urllib
_stat               et_xmlfile          profile             urllib3
_string             fastcache           prompt_toolkit      uu
_strptime           faulthandler        pstats              uuid
_struct             filecmp             psutil              venv
_symtable           fileinput           pty                 warnings
_system_path        filelock            py                  wave
_testbuffer         flask               py_compile          wcwidth
_testcapi           flask_cors          pyclbr              weakref
_testconsole        fnmatch             pycodestyle         webbrowser
_testimportmultiple formatter           pycosat             webencodings
_testmultiphase     fractions           pycparser           werkzeug
_thread             ftplib              pycurl              wheel
_threading_local    functools           pydoc               widgetsnbextension
_tkinter            gc                  pydoc_data          win2kras
_tracemalloc        genericpath         pyexpat             win32api
_warnings           getopt              pyflakes            win32clipboard
_weakref            getpass             pygments            win32com
_weakrefset         gettext             pylab               win32con
_win32sysloader     gevent              pylint              win32console
_winapi             glob                pyodbc              win32cred
_winxptheme         glob2               pyparsing           win32crypt
_yaml               greenlet            pytest              win32cryptcon
abc                 gzip                pytest_arraydiff    win32event
adodbapi            h5py                pytest_doctestplus  win32evtlog
afxres              hashlib             pytest_openfiles    win32evtlogutil
aifc                heapdict            pytest_remotedata   win32file
alabaster           heapq               pythoncom           win32gui
anaconda_navigator  hmac                pytz                win32gui_struct
anaconda_project    html                pywin               win32help
antigravity         html5lib            pywin32_testutil    win32inet
argparse            http                pywintypes          win32inetcon
array               idlelib             pywt                win32job
asn1crypto          idna                pyximport           win32lz
ast                 imageio             qtawesome           win32net
astroid             imagesize           qtconsole           win32netcon
astropy             imaplib             qtpy                win32pdh
asynchat            imghdr              queue               win32pdhquery
asyncio             imp                 quopri              win32pdhutil
asyncore            importlib           random              win32pipe
atexit              inspect             rasutil             win32print
attr                io                  re                  win32process
audioop             ipaddress           regcheck            win32profile
autoreload          ipykernel           regutil             win32ras
babel               ipykernel_launcher  reprlib             win32rcparser
backcall            ipython_genutils    requests            win32security
backports           ipywidgets          rlcompleter         win32service
base64              isapi               rmagic              win32serviceutil
bdb                 isort               rope                win32timezone
binascii            itertools           ruamel_yaml         win32trace
binhex              itsdangerous        run                 win32traceutil
binstar_client      jdcal               runpy               win32transaction
bisect              jedi                sched               win32ts
bitarray            jinja2              scipy               win32ui
bkcharts            json                scripts             win32uiole
blaze               jsonschema          seaborn             win32verstamp
bleach              jupyter             secrets             win32wnet
bokeh               jupyter_client      select              win_inet_pton
boto                jupyter_console     selectors           win_unicode_console
bottleneck          jupyter_core        send2trash          wincertstore
brain_attrs         jupyterlab          servicemanager      winerror
brain_builtin_inference jupyterlab_launcher setuptools          winioctlcon
brain_collections   keyword             shelve              winnt
brain_curses        kiwisolver          shlex               winperf
brain_dateutil      lazy_object_proxy   shutil              winpty
brain_fstrings      lib2to3             signal              winreg
brain_functools     linecache           simplegeneric       winsound
brain_gi            llvmlite            singledispatch      winxpgui
brain_hashlib       locale              singledispatch_helpers winxptheme
brain_io            locket              sip                 wrapt
brain_mechanize     logging             sipconfig           wsgiref
brain_multiprocessing lxml                sipdistutils        xdrlib
brain_namedtuple_enum lzma                site                xlrd
brain_nose          macpath             six                 xlsxwriter
brain_numpy         macurl2path         skimage             xlwings
brain_pkg_resources mailbox             sklearn             xlwt
brain_pytest        mailcap             smtpd               xml
brain_qt            markupsafe          smtplib             xmlrpc
brain_re            marshal             sndhdr              xxsubtype
brain_six           math                snowballstemmer     yaml
brain_ssl           matplotlib          socket              zict
brain_subprocess    mccabe              socketserver        zipapp
brain_threading     menuinst            socks               zipfile
brain_typing        mimetypes           sockshandler        zipimport
brain_uuid          mistune             sortedcollections   zlib
bs4                 mkl                 sortedcontainers    zmq
builtins            mkl_fft             sphinx              

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".

So it looks like quandl isn't showing up there, which is weird because it shows up when I use the list command in the command prompt.

Boris Galerkin posted:

Which command line commands don't work for you?

According to the python documentation website (https://docs.python.org/3/installing/index.html#installing-index) I should be able to install using

python -m pip install SomePackage



But to get it to work on my shells I use:

py -m pip install somepackage


So I guess not a command per se. I don't know why it's different on my system, but works just fine for others using the same OS and IDE.

Here's a copy/past of my command prompt install (well you get what I mean), and as far as I can tell it looks like everything loaded just fine.

C:\WINDOWS\system32>py -m pip install quandl
Requirement already satisfied: quandl in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (3.4.1)
Requirement already satisfied: more-itertools in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (4.3.0)
Requirement already satisfied: inflection>=0.3.1 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (0.3.1)
Requirement already satisfied: requests>=2.7.0 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (2.19.1)
Requirement already satisfied: pandas>=0.14 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (0.23.4)
Requirement already satisfied: six in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (1.11.0)
Requirement already satisfied: numpy>=1.8 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (1.14.5)
Requirement already satisfied: python-dateutil in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from quandl) (2.7.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from requests>=2.7.0->quandl) (2018.4.16)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from requests>=2.7.0->quandl) (1.23)
Requirement already satisfied: idna<2.8,>=2.5 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from requests>=2.7.0->quandl) (2.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from requests>=2.7.0->quandl) (3.0.4)
Requirement already satisfied: pytz>=2011k in c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages (from pandas>=0.14->quandl) (2018.5)

a forbidden love
Apr 28, 2005

"It was never meant to beep boop be"
And now I just found out that I also can't import "tflearn" (tensorflow). I guess Turing just doesn't want to let me learn about ML or AI :(

Edit:

It's also not listed in the "modules" prompt, but also does show up in the "list" prompt.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

I really want to like pipenv but I just can't because it feels like it's a buggy cryptic mess and nothing it tells me/outputs makes any sense at all.

For example I just created a new pipenv with the following Pipfile:

code:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
scipy = "*"
pandas = "*"

[dev-packages]

[requires]
python_version = "3.6"
Everything works great. Now I add jupyter and it gives me this mess of an output:

code:
Successfully installed [...] widgetsnbextension-3.4.0

Adding jupyter to Pipfile's [packages]...

Pipfile.lock (94e126) out of date, updating to (52d57c)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
Could not find a version that matches widgetsnbextension==3.3.1,~=3.3.0,~=3.4.0
Tried: [...], 3.4.0, 3.4.0
Skipped pre-versions: [...]
There are incompatible versions in the resolved dependencies.
So pipenv tells me it installed widgetsnbextension-3.4.0, and then it tells me that it can't find a compatible version of widgetsnbextension that matches either 3.3.1, 3.3.0+, or 3.4.0+. Then it also tells me that it tried to install version 3.4.0 (twice), but for some reason it doesn't think 3.4.0 matches version number 3.4.0.

It was a fun experience but back to conda environments I go.

e: Meanwhile, jupyter was successfully installed in this pipenv and it works fine. What the hell does any of this even mean.

pipenv is kind of weird still, but note that it just gave you a warning, not an error.

pipenv could be more helpful in explaining what happened here, but I think what its telling you is that the sub-dependencies of your dependencies declare require versions of widgetsnbextension that are not resolvable. In other words:

1. one sub-dependency requires exactly version 3.3.1.
2. one sub-dependency requires 3.3.*
3. one sub-dependency requires 3.4.*

There is not a version you can install that meets all of the requirements at the same time. Pipenv defaults to installing the latest version and does so, and thats why things actually work. Libraries generally don't check the versions of their sub-dependencies at runtime, so the package that required 3.3.1 and the package and 3.3.* go ahead and just do their imports and use the code and you just happen to luck out that those packages don't use any APIs whose behavior changed between 3.3 and 3.4.

Or maybe the behavior has changed, but it's in a subtle way that will not cause a crash but will cause errors is your data!

Anyway, pipenv can't fix this poo poo, but it could give better warning messages.

Of note, your conda environments have the exact same problem, its just that you don't even get a warning.

dependencies and dependency resolution is poo poo and we develop on a house of cards

Thermopyle fucked around with this message at 19:48 on Aug 16, 2018

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!

Thermopyle posted:

pipenv is kind of weird still, but note that it just gave you a warning, not an error.

pipenv could be more helpful in explaining what happened here, but I think what its telling you is that the sub-dependencies of your dependencies declare require versions of widgetsnbextension that are not resolvable. In other words:

1. one sub-dependency requires exactly version 3.3.1.
2. one sub-dependency requires 3.3.*
3. one sub-dependency requires 3.4.*

There is not a version you can install that meets all of the requirements at the same time. Pipenv defaults to installing the latest version and does so, and thats why things actually work. Libraries generally don't check the versions of their sub-dependencies at runtime, so the package that required 3.3.1 and the package and 3.3.* go ahead and just do their imports and use the code and you just happen to luck out that those packages don't use any APIs whose behavior changed between 3.3 and 3.4.

Or maybe the behavior has changed, but it's in a subtle way that will not cause a crash but will cause errors is your data!

Anyway, pipenv can't fix this poo poo, but it could give better warning messages.

Of note, your conda environments have the exact same problem, its just that you don't even get a warning.

dependencies and dependency resolution is poo poo and we develop on a house of cards

I found on one of their closed GitHub issues that apparently the "*" version signifier doesn't mean wildcard as it does in every other usage in the world, but instead it means "latest version." I don't really have anything constructive to say about that so it's whatever.

Maybe I assumed too much, but I thought that specifying wildcards for every package would be translated to "I don't care which versions you use, just get me the latest compatible versions of every package I listed." Isn't that what requirements.txt does if you just list packages and not versions?

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!

I am not 100% positive about this but it looks like you are having this issue because you are installing your packages into one environment and then trying to use it with a different environment; i.e, when you say you installed it from the command line you installed it into environment A, but then in your Anaconda IDE it is using environment B, and also in your MVS IDE you are yet again using environment C. I'm assuming this based on the paths in your post:

code:
C:\Users\Family\Anaconda3\lib\site-packages
and

code:
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages
and if you've installed python from python.org you probably(?) have an installation in

code:
c:\python3.6
or similar.

This is just a guess cause I've never used the IDEs you use and I have no idea how Windows handles paths and such but I wouldn't be surprised if each of your IDEs installed their own built-in/default python.exe interpreters and by default they are using those, which isn't the same one that you "use" when you just type "py blah blah" into your command prompt. I would suggest looking into your IDE documentation and seeing if there's an option to specify which interpreter/environment to use. Someone else who uses Windows/those IDEs is gonna need to help you here.

Maybe https://code.visualstudio.com/docs/python/environments helps you out?

a forbidden love posted:

According to the python documentation website (https://docs.python.org/3/installing/index.html#installing-index) I should be able to install using

python -m pip install SomePackage

But to get it to work on my shells I use:

py -m pip install somepackage

No idea. Maybe someone else who uses Windows can answer that.

Boris Galerkin fucked around with this message at 08:50 on Aug 17, 2018

NtotheTC
Dec 31, 2007


Boris Galerkin posted:

I found on one of their closed GitHub issues that apparently the "*" version signifier doesn't mean wildcard as it does in every other usage in the world, but instead it means "latest version." I don't really have anything constructive to say about that so it's whatever.

Maybe I assumed too much, but I thought that specifying wildcards for every package would be translated to "I don't care which versions you use, just get me the latest compatible versions of every package I listed." Isn't that what requirements.txt does if you just list packages and not versions?

Give Poetry a try. It does everything pipenv does but without some of the dafter design decisions (like upgrading your packages by default)

pmchem
Jan 22, 2010


For those of you who use Python for scientific computing, do you use Spyder as your editor / development environment?

If "yes", what changes/features would you like to see in it?
If "no", what changes/features would convince you to use it?

If you don't know what I'm talking about, check out Spyder here: https://github.com/spyder-ide/spyder . It's the default IDE for the Anaconda Python distribution.

I may have the chance to work on enhancing Spyder with a hardcore python dev. I'm genuinely interested in serious replies, thanks!

BaronVonVaderham
Jul 31, 2011

All hail the queen!

pmchem posted:

For those of you who use Python for scientific computing, do you use Spyder as your editor / development environment?

If "yes", what changes/features would you like to see in it?
If "no", what changes/features would convince you to use it?

If you don't know what I'm talking about, check out Spyder here: https://github.com/spyder-ide/spyder . It's the default IDE for the Anaconda Python distribution.

I may have the chance to work on enhancing Spyder with a hardcore python dev. I'm genuinely interested in serious replies, thanks!

Coming from an astrophysics perspective, I prefer to use Jupyter notebooks for a lot of my work (which runs as a local server you load in a browser tab). I use PyCharm generally for my standalone scripts and such, but I like using Jupyter for compiling and presenting my work since I can inline LaTeX blocks, plots, etc.

I've never heard of Spyder and I don't know enough to have an opinion on it yet, but I'll add it to the long list of new things to look into.

pmchem
Jan 22, 2010


BaronVonVaderham posted:

Coming from an astrophysics perspective, I prefer to use Jupyter notebooks for a lot of my work (which runs as a local server you load in a browser tab). I use PyCharm generally for my standalone scripts and such, but I like using Jupyter for compiling and presenting my work since I can inline LaTeX blocks, plots, etc.

I've never heard of Spyder and I don't know enough to have an opinion on it yet, but I'll add it to the long list of new things to look into.

Not sure what your Python installation is like, but Spyder is installed by default if you're using the Anaconda Distribution: https://www.anaconda.com/download/

I'm very familiar with Jupyter notebooks, yeah. I use 'em sometimes.

unpacked robinhood
Feb 18, 2013

by Fluffdaddy
I'm trying to apply a function f(x,y) to each possible combination of two strings in a list.

Python code:
    names = ['joel','barney','georges','amsterdam']
    # 4 is a random placeholder value
    d = pd.DataFrame(4,names,names)
code:
           joel  barney  georges  amsterdam
joel          4       4        4          4
barney        4       4        4          4
georges       4       4        4          4
amsterdam     4       4        4          4
I'd like to compute a value for each cell (in my case the Levenshtein distance) using the row index and column index as value.
Googling gets me vague and complicated answers so I'm probably not going in the right direction ?

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
pretty easy with itertools.product if and only if you don't need it in the dataframe (aka, you don't need it super fuckin fast)

the keyword is cartesian product. for the dealio in pandas, see:

https://stackoverflow.com/questions/13269890/cartesian-product-in-pandas

Eela6
May 25, 2007
Shredded Hen

unpacked robinhood posted:

I'm trying to apply a function f(x,y) to each possible combination of two strings in a list.

Python code:
    names = ['joel','barney','georges','amsterdam']
    # 4 is a random placeholder value
    d = pd.DataFrame(4,names,names)
code:
           joel  barney  georges  amsterdam
joel          4       4        4          4
barney        4       4        4          4
georges       4       4        4          4
amsterdam     4       4        4          4
I'd like to compute a value for each cell (in my case the Levenshtein distance) using the row index and column index as value.
Googling gets me vague and complicated answers so I'm probably not going in the right direction ?

This is a great place for a generator or list comprehension.


IN
Python code:
def add(x,y): 
     return x+y

print([ [f(x,y) for x in 'abc'] for y in 'abc'])
OUT:
pre:
[['aa', 'ba', 'ca'], ['ab', 'bb', 'cb'], ['ac', 'bc', 'cc']]

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
you just reimplemented itertools.product but not w/ a generator

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

unpacked robinhood posted:

I'm trying to apply a function f(x,y) to each possible combination of two strings in a list.

Python code:
    names = ['joel','barney','georges','amsterdam']
    # 4 is a random placeholder value
    d = pd.DataFrame(4,names,names)
code:
           joel  barney  georges  amsterdam
joel          4       4        4          4
barney        4       4        4          4
georges       4       4        4          4
amsterdam     4       4        4          4
I'd like to compute a value for each cell (in my case the Levenshtein distance) using the row index and column index as value.
Googling gets me vague and complicated answers so I'm probably not going in the right direction ?

Using your d, maybe something like this?

Python code:
for col_key, row in d.iterrows():
    for row_key in row.keys():
        d[col_key][row_key] = levenshtein_distance(col_key, row_key)

unpacked robinhood
Feb 18, 2013

by Fluffdaddy
Thanks ! I ended up using Eela6's proposition, alhough I find Symbolic Butt's one more readable.

It looks like this :
Python code:
names = pd.Series(['joel', 'barney', 'georges', 'amsterdam'])
lev = [[(Levenshtein.distance(x, y)) for x in names] for y in names]
df = pd.DataFrame(lev, names, names)

unpacked robinhood fucked around with this message at 18:40 on Aug 20, 2018

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Boris Galerkin posted:

I found on one of their closed GitHub issues that apparently the "*" version signifier doesn't mean wildcard as it does in every other usage in the world, but instead it means "latest version." I don't really have anything constructive to say about that so it's whatever.

Maybe I assumed too much, but I thought that specifying wildcards for every package would be translated to "I don't care which versions you use, just get me the latest compatible versions of every package I listed." Isn't that what requirements.txt does if you just list packages and not versions?

The problem isn't your requirements, its the requirements of your requirements.

Apparently, there does not exist a fully-compatible set of your requirements. This is just the first time you've found that out because pipenv is the first tool you've used that bothers to tell you.

Mark Larson
Dec 27, 2003

Interesting...
Loading data from an API to a database... the fastest way possible.

I'm trying to load data from an API, I get 100 objects per call. I'd like to load them all at once, with an INSERT statement that looks like this...

INSERT INTO t(col1, col2, col3) VALUES ((1,2,3), (2,,4), (4,5,6), (4,3,2)) ... etc.

Now the trick is that not all columns are present in all items of the json response/dictionary. I was working around this by getting the keys and the values and then putting them into an INSERT statement, however this worked per line and is unbearably slow. I kinda got the gist of what I need to do from here: https://stackoverflow.com/questions/8134602/psycopg2-insert-multiple-rows-with-one-query

So, now I'm assigning all the columns to a list that I can call with the cur.execute() function, but need to make sure that if a value doesn't exist, it returns NULL or adds a comma, so the number of columns is always the same. Can anyone help?

code:
cols_sql_arg = 'INSERT INTO table (%s) VALUES (%s)'
for entry in json_dict :
        
        print("Loading thing_id:", entry.thing.id)
        try:
            if 'addons' in entry.thing.values:
                addons_list = entry.thing.values.pop('addons')
                for addon in addons_list:
                    addons_columns = ', '.join(map(str, addon.keys())) + ', thing_id'
                    addons_rows = ', '.join(map(repr, addon.values())) + ', ' + repr(entry.thing.id)
                    cur.execute(addons_sql_arg % (addons_columns, addons_rows))
            #sub_columns = ', '.join(map(str, entry.thing.values.keys())) -- this is what I have been using 
            sub_rows = ', '.join(map(repr, entry.thing.values.values()))
            #  print(cur.mogrify(cols_sql_arg % (sub_columns, sub_rows)))
            cur.execute(cols_sql_arg % (sub_columns, sub_rows))
            print("Loaded columns.")
            
        except Exception as e:
            print("Error: ", e)
    conn.commit()

Mark Larson fucked around with this message at 16:38 on Aug 22, 2018

cinci zoo sniper
Mar 15, 2013




If you want it to just work, and not optimally fast, then create a column base dict (e.g. {'A': None, 'B': None}), and the do loop over keys and values, updating copy of that dict that you then throw into your insert.

Mark Larson
Dec 27, 2003

Interesting...

cinci zoo sniper posted:

If you want it to just work, and not optimally fast, then create a column base dict (e.g. {'A': None, 'B': None}), and the do loop over keys and values, updating copy of that dict that you then throw into your insert.

What would be the fast way then?

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost
slightly comedy option: make a csv, do a COPY, if your rdbms is chill with that

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




Mark Larson posted:

What would be the fast way then?

Bulk inserts through SQLAlchemy ORM bulk suite, or some flavour of inserts through SQLAlchemy core.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply