Using conditional to generate new column in pandas dataframe

You can define a function which returns your different states “Full”, “Partial”, “Empty”, etc and then use df.apply to apply the function to each row. Note that you have to pass the keyword argument axis=1 to ensure that it applies the function to rows. import pandas as pd def alert(row): if row[‘used’] == 1.0: return … Read more

Python Pandas Select Index where index is larger than x

Example of selecting from a DataFrame with the use of index: from numpy.random import randn from pandas import DataFrame from datetime import timedelta as td import dateutil.parser d = dateutil.parser.parse(“2014-01-01”) df = DataFrame(randn(6,2), columns=list(‘AB’), index=[d + td(days=x) for x in range(1,7)]) In [1]: df Out[1]: A B 2014-01-02 -1.172285 1.706200 2014-01-03 0.039511 -0.320798 2014-01-04 -0.192179 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)