Stacked area plot and dates in matplotlib

Here is my code: import datetime as dt import matplotlib.pyplot as plt import matplotlib.dates as mdates dates = ['2014-12-15','2015-11-07','2016-01-10'] x = [dt.datetime.strptime(d,'%Y-%m-%d').date() for d in dates] plt.gca().xaxis.set_major_forma...
more »

2017-02-22 21:02 (1) Answers

how to verified the string as correct date format

can I know the best way for me to verified the string is in the following formate. I am not sure how i should verified the house and (am or pm) datestring = 'Feb 22 2017, 1:27:42pm' print(datetime.strptime('Feb 22 2017, 1:27:42', '%b %d %Y, %H:%m:%S...
more »

2017-02-22 20:02 (2) Answers

Spyder pip install not found: OSX

So I have installed spyder through the pip install spyder command on my terminal. When I type pip show spyder I receive: Name: spyder Version: 3.1.3 Summary: Scientific PYthon Development EnviRonment Home-page: A...
more »

2017-02-22 17:02 (1) Answers

TimeoutError when using python to send email

I'm trying to write a python script to send an email. And here is the code: def main(): import smtplib import email.mime.text import email.mime.application from email.mime.multipart import MIMEMultipart from_email = 'xxx@gmail...
more »

2017-02-22 16:02 (0) Answers

Grouping columns in a Pandas Dataframe

I would be grateful if someone could help me with a pandas dataframe problem I am having. I am trying to group a pandas dataframe by columns but am unsure how to proceed. I have a dataframe with duplicate column names (A's and B's) and would like t...
more »

2017-02-22 16:02 (1) Answers

Change value of column on condition

I have an example of Dataframe df: Col1 Col2 a "some string AXA some string " b "some string2" I would like to: if df.Col2 contains "AXA" then change the value to 1, if not then change it to 0. So I get: Col1 ...
more »

2017-02-22 14:02 (1) Answers

How to one hot encode variant length features?

Given a list of variant length features: features = [ ['f1', 'f2', 'f3'], ['f2', 'f4', 'f5', 'f6'], ['f1', 'f2'] ] where each sample has variant number of features and the feature dtype is str and already one hot. In order to use feat...
more »

2017-02-22 13:02 (2) Answers

how to create a class built on

I am writing a module that converts between several different file formats (e.g. vhdl to verilog, excel table to vhdl etc). Its not so hard but there is a lot of language specific formatting to do. It just occurred to me that an elegant way to do t...
more »

2017-02-22 10:02 (2) Answers

Printing a dict of lists as a grid-layout

Ok, I read all of these before and I think pandas could be a solution, but my problem is slighly different: Print a dictionary of lists vertically Printing Lists as Tabular Data print dictionary values which are inside a list in python Print a dictio...
more »

2017-02-22 10:02 (3) Answers

pandas replace only part of a column

Here is my input: import pandas as pd import numpy as np list1 = [10,79,6,38,4,557,12,220,46,22,45,22] list2 = [4,3,23,6,234,47,312,2,426,42,435,23] df = pd.DataFrame({'A' : list1, 'B' : list2}, columns = ['A', 'B']) df['C'] = np.where (df['A'] &g...
more »

2017-02-22 03:02 (2) Answers

smtplib not available for anaconda distribution?

I am trying to have my code send me an email once it stops running so I know to go check on it. I have found that a simple way of doing this is by importing the smtplib package, as examples of this code can be seen here: How to send an email with Pyt...
more »

2017-02-21 21:02 (0) Answers

Time series plotted with imshow

I tried to make the title as clear as possible although I am not sure it is completely limpid. I have three series of data (number of events along time). I would like to do a subplots were the three time series are represented. You will find attached...
more »

2017-02-21 19:02 (1) Answers