Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
What is the fastest method to write a function for time series calculation that counts consecutive values in the same series ? A For loop or vector
Here is what my data looks like:
enter image description here
You can use rolling function to calculate the sum of 4 consecutive hours
df.consumption4hr = df.Consumption.groupby(level='Accounts').rolling(window=4).sum()
with that you can just find the list of accounts that has 0 in that column. for example:
df[df.consumption4hr == 0].Accounts.unique()
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have dataframe like this
enter image description here
I need to find out the average close days of request Recycling
Please help me.
You can group by request and get the average.This will give average for each group
df.groupby("request")["Days to Close"].mean()
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
If two list is having same number, then the final list should not have the number
If your lists contains unique elements, consider using sets instead.
https://docs.python.org/2/library/sets.html
Check this code:
ls=[1,2,3,4,5,5]
ls1=[1,2,3,4,5,7,8,9]
common_elements=set(ls).intersection(set(ls1))
for i in common_elements:
if ls.__contains__(i):
ls.remove(i)
if ls1.__contains__(i):
ls1.remove(i)
final_ls=ls+ls1
print(final_ls)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
For the above example,
I want to have a look at the value of outlet_size when Outlet_identifier = OUT049 or any value for that instance.
I don't want to produce a new dataframe object and then print it, instead I want to know if there is any function or way to directly view it.
For both columns
df.loc[df['Outlet_identifier'].eq('OUT049'), ['Outlet_identifier', 'outlet_size']]
you can do that with pandas like this :
df = pd.DataFrame({'Outlet_identifier': ['OUT049','OUT018','OUT049'], 'outlet_size':
[2.0, 2.0, 2.0]})
df[df["Outlet_identifier"]=="OUT049"]["outlet_size"]
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am using Python with Pandas. How can I multiply a column by 1000 given another column has a certain string?
This should do it.
df['columnname'] = np.where(df['othercolumn'] == 'CertainString',
df['columnname'] * 1000,
df['columnname'])
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a list of csv file which contains several columns.
There's one that contains the lenght of my test in this format hh:mm:ss
I need to divide this data in two database based on lenght: <00:16:00 or >00:16:00
How can I do that?
Thanks for helping and sorry for my bad english.
Brute force:
value = "00:15:47" # taken from csv
if value < "00:16:00":
# handle smaller values
else:
# handle bigger values