I have a df like so: I want to flatten the df so it is one continuous list like so: [‘1/2/2014’, ‘a’, ‘6’, ‘z1’, ‘1/2/2014’, ‘a’, ‘3’, ‘z1′,’1/3/2014’, ‘c’, ‘1’, ‘x3’…
Tag: python
Running bpython inside a virtualenv
I have created a virtualenv and installed SQLAlchemy in it: import works in python: But it does not work in bpython: Why can’t bpython find the package installed in the virtualenv, even though it is executed after source alchemy/bin/activate is called? Answer bpython must be installed in the virtualenv,…
ImportError: No module named _mssql
I’m running Python 2.7.2 on OS 10.8.5 Trying to use pymssql, but I get the following error: I’ve tried installing mssql with pip and brew only to be told that there’s no package by that name. The docs don’t seem to cover installation. EDIT: When I try to pip install pymssql I get: So I…
How to extract base path from DataFrame column of path strings
There are several questions about string manipulation, but I can’t find an answer which allows me to do the following—I thought it should have been simple… I have a DataFrame which includes a column containing a filename and path The following produces a representative example DataFrame: I want to…
Error When Trying to Run Simple Kivy Program (Windows)
When trying to run the following program on my computer: After I added what was suggested( The last two lines ), I get two syntax errors, the first telling me to delete the colon and the second telling me to remove the indent, and then this: According to the tutorial I’m following( http://inclem.net/201…
Create Python DataFrame from dictionary where keys are the column names and values form the row
I am familiar with python but new to panda DataFrames. I have a dictionary like this: And I would like to convert it to a DataFrame, where b and c are the column names, and the first row is 100,300 (100 is underneath b and 300 is underneath c). I would like a solution that can be generalized to a
Pandas versions compatible with specific python and numpy configurations?
Is there a programmatic way to find out which pandas versions are compatible with specific python and numpy configurations? My interest is to get pandas going within ESRI ArcMAP 10.1, which runs on 32-bit Windows and is built on python 2.7, numpy 1.6. I tried creating a conda environment for Python compatible…
“Models aren’t loaded yet” error while populating in Django 1.8 or later
I am using this code to populate my database: On running It gives the error: Rest of my files are ok but getting this error. I am following the tutorial from Tango with Django book but as the book refers to Django 1.5.4 and i am using Django 1.8, so can anyone help me here? Answer I had the same
Setting plot background colour in Seaborn
I am using Seaborn to plot some data in Pandas. I am making some very large plots (factorplots). To see them, I am using some visualisation facilities at my university. I am using a Compound screen made up of 4 by 4 monitors with small (but nonzero) bevel — the gap between the screens. This gap is black…
Filtering multiple items in a multi-index Python Panda dataframe
I have the following table: Note: Both NSRCODE and PBL_AWI are indices. How do I search for values in column PBL_AWI? For example I want to keep the values [‘Lake’, ‘River’, ‘Upland’]. Answer You can get_level_values in conjunction with Boolean slicing. The same idea can be…