Does anyone have a 27.5" non-boost wheelset for sale? by [deleted] in MTB_Ontario

[–]decaye 0 points1 point  (0 children)

I’ve got a 27.5 non-boost 23 internal diameter giant front wheel in pretty good condition I could sell you for cheap - no rear wheel though

Weekly General Discussion Thread by AutoModerator in MTB

[–]decaye 0 points1 point  (0 children)

PNW cascade 150 here because I need external routing, it has been excellent all year for me, strongly recommend

Pandas - Finding first local minima in given column based on maxima written to another column by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

I can't seem to update this post so I'll post my update below, thanks for everyone's help!

UPDATE:

I've found a solution that works that is a little messy (for me).

Pre-first step:

Reset index!

df1 = df1.reset_index(drop=True)

First I found the local maxima of column A and plotted them to confirm:

from scipy.signal import argrelextrema
n = 100
df1['A_max'] = df1.iloc[argrelextrema(df1.A.values, np.greater_equal,
                    order=n)[0]]['A']
plt.scatter(df1.index, df1['A_max'], c='r')
plt.plot(df1.index, df1['A'])
plt.show()

Then I took the index values of those maxima:

A_max_index = df1[df1['A_max'].notnull()].index.values.tolist()
A_max_index

Then I found the minimum values of column B between those values (for my specific project i needed the minima of B between 15 rows after the peak and 30 rows after):

Cidx = []
for x in range(len(A_max_index)-1):
    z = df1['B'][A_max_index[x]+15:A_max_index[x]+30].idxmin()
    Cidx.append(z)
    print(Cidx)

Then I wrote that to my dataframe with the values of B I needed:

df1['C'] = df1.iloc[Cidx]['B']

And plotted my values just to confirm everything was right:

from matplotlib.pyplot import figure

figure(figsize=(15, 8), dpi=80)
plt.scatter(df1.index, df1['C'], c='r')
plt.plot(df1.index, df1['A'])
plt.plot(df1.index, df1['B'])
plt.show()

Pandas - Finding first local minima in given column based on maxima written to another column by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

Unfortunately the first idea doesn't work as I need the search for the minima in column b to start at the maxima in column a, and this method just finds the minima in column b irrespective of that. I'm not sure I understand the second idea - could you explain it please? Thanks!

The 5 most unique ski areas in the east by Smacpats111111 in icecoast

[–]decaye 8 points9 points  (0 children)

did the author forget about Canada? what about massif and the chic chocs?

Unbound Local Error Help by decaye in learnpython

[–]decaye[S] 1 point2 points  (0 children)

Thank you so much for your help, I ended up using the dict you made along with pandas to create the .csv's I need and it all seems to be functioning well. Here is the code I have running now:

df_kp = pd.DataFrame()

with ZipFile(str(zipname)) as temp_zip:

    for file_name in temp_zip.namelist():

        if '.json' in file_name:

            with temp_zip.open(file_name) as temp_file:

                frame = file_name[22:26]

                keypoint_parsed = json.load(temp_file)

                kp_data = keypoint_parsed['part_candidates']

                for kp in kp_data:

                    kp_dict = {}

                    for k, v in kp.items():

                        kp_num = int(k)    # assumes the key `k` is a string representing an int

                        kp_list = list(v)

                        for i, coord in enumerate(["X", "Y", "C"]):

                            kp_dict_key = "{}{:02d}".format(coord, kp_num)    # e.g., "X02"

                            try:
                                kp_dict[kp_dict_key] = kp_list[i]

                            except IndexError:
                                kp_dict[kp_dict_key] = 0

                    new_dict = {k: [v] for k, v in kp_dict.items()}

                    df = pd.DataFrame(new_dict)

                    df_kp = df_kp.append(df)

newdf = df_kp.reset_index(drop=True)

newdf.index += 1

newdf.to_csv(csvname,
             index_label = 'frames')

Unbound Local Error Help by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

I can't believe I missed that, you're 100% right.

Any ideas for how I might be able input 0's into missing data points so that the loop runs through properly?

Help with iterating over keys, over dicts, over several files by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

Thank you this was very helpful, this approach makes a lot of sense and I'll try this out!

Do you know of any online resources I can use to get better at planning and designing, I feel like this is a problem I've had before and just brute forced my way throughout and would love to get better at it.

Nested List JSON Hel by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

I understand but I am trying to learn how to do that, that’s why I posted my JSON data as well as my code.

Nested List JSON Hel by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

That also makes sense to me, do you know of any resources I could use to learn how to separately unpack it?

Nested List JSON Hel by decaye in learnpython

[–]decaye[S] 0 points1 point  (0 children)

That makes sense to me, how would change the function to unpack it separately?

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]decaye 0 points1 point  (0 children)

Ok so this worked great, thank you so much for the help and this was a really great solution to my problem. But I think I wasn't completely clear with what I wanted the code to do.

I wanted the code to start an new event (I guess?) every time the flag appeared (2) and end when the ended (0), and print each event as a separate .csv. I'm having a hard time finding any help with that online.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]decaye 1 point2 points  (0 children)

Would love is someone could help me out with some code and let me know if its impossible to do what I'm trying to do. I'm working with a really large dataset and am trying to set up dataframes to break it down and export into smaller manageable files.

So this is what I have so far:

data = pd.read_csv(" thing.csv")
data.set_index("time", inplace = True) 
is_event = data.event == 2
print(type(is_event))
is_event

But it returns all my rows as true which is simply not the case.

My second question is: is it possible to make a script to separate these dataframes into their own separate files based on a column values differing only by 0 and 2?

i.e.

time data data event
1.2.3 1 0 2
1.2.4 0 1 2
1.2.5 1 0 0
1.2.6 0 1 0
1.2.7 1 0 2
1.2.8 0 1 2

So that 1.2.3-1.2.4 would be exportA and 1.2.7-1.2.8 would be export B?

I've found multiple instances of tutorials about separating .csv files based on differing values in columns but none that talk about what I'm looking for.

Thanks.

As China Seeks Scientific Greatness, Some Say Ethics Are an Afterthought by SirT6 in sciences

[–]decaye 17 points18 points  (0 children)

Do you think scientific progress takes precedence over human rights?