Skip to content

Tag: python

Why does pyPdf2.PdfFileReader() require a file object as an input?

csv.reader() doesn’t require a file object, nor does open(). Does pyPdf2.PdfFileReader() require a file object because of the complexity of the PDF format, or is there some other reason? Answer It’s just a matter of how the library was written. csv.reader allows any iterable that returns strings (…

Ordered Logit in Python?

I’m interested in running an ordered logit regression in python (using pandas, numpy, sklearn, or something that ecosystem). But I cannot find any way to do this. Is my google-skill lacking? Or is this not something that’s been implemented in a standard package? Answer Update: Logit and Probit Ord…

Matplotlib error: libfreetype.6.dylib

I’m trying to run the following python script (I’m using Vim): When I do, I get the following: I tried reinstalling brew, reinstalling freetype, matplotlib, and numpy in brew, and I uninstalled MacPorts with no change in the error. Suggestions? EDIT: After uninstalling MacPorts and then doing anot…

zip file and avoid directory structure

I have a Python script that zips a file (new.txt): When I do this I get the zip file. But when I try to unzip the file I get the text file inside of a series of directories corresponding to the path of the file i.e I see a folder called root in the result directory and more directories within