Make Python Code blazing fast (test code)

Ditutup Dipasang 1 tahun yang lalu Dibayar saat pengiriman
Ditutup Dibayar saat pengiriman

Hello and thank you for your time. Please read the entire description carefully and reach out if you have any questions. Before awarding the project, there is a small test - 11 lines of code. If you are not comfortable with tests, please DO NOT bid.

So, I am in the process of building a model in Python and the entire file has about 1500 lines of codes and there are like 5 such files. I need help making these codes blazing fast. For the benefit of both you and me, I am sharing a sample code (test code) of a situation where I am dealing with a pandas dataframe that is at least 300,000 rows and 11 columns. I have a nested for loop to label the dataframe for each row in a new column.

The code is just 11 lines and I would like to see the performance comparison from your submission. Please note that this is a test job and based on the best submission I will move ahead with the full project. There is more work that these 5 files to be done too.

You are free to try eliminating for loops, using numpy vectorization, pandas vectorization but the end goal is to execute this blazing fast. For your reference the code is given below and sample data is also attached. Kindly submit your code and comparison times running the code as it is and your vectorized code for evaluation.

This is a test job so I am not paying anything for 11 lines of code. This is the evaluation criteria for the bigger project. I will be discussing timeline and costing once finalized.

Code -

for i in range(len(df) - timeframe):

calc = df['Close'].iloc[i] * (1 + percentage)

subset = df['Close'].iloc[i+1:i+timeframe+1]

if percentage < 0:

direction = 'short'

else:

direction = 'long'

for price in subset:

if (direction == 'long' and price >= calc) or (direction == 'short' and price <= calc):

df['label'].iloc[i] = 1

break

df = dataframe

percentage = variable (assign any value you want for trial)

timeframe = variable (assign any value you want for trial)

long and short = labels

Close = column in df

label = column in df (to be created)

Python Perancangan Perangkat Lunak Vectorization NumPy Pandas

ID Proyek: #36174099

Tentang proyek

8 proposal Proyek online Aktif 11 bulan yang lalu

8 freelancer rata-rata menawar $23 untuk pekerjaan ini

AhmedHassan20221

Hi, iam data analyst with great experience in data preprocessing using pandas and numpy. please send me the sample data and i will revert back with the results. Thanks

$20 CAD dalam 7 hari
(14 Ulasan)
4.0
robartint

Hello I am a professional python developer. My main specializations are automation, web scrapers and bots development. I have already developed over 200 scrapers. From the simplest (for example, a competitor's price Lebih banyak

$10 CAD dalam 7 hari
(10 Ulasan)
4.1
snmurad

Hey, I have read the descriptions. I have no issue with writing the test program. But there is no file attached in the bid description. I can write the code and send you the output but please can you send the data file Lebih banyak

$30 CAD dalam 1 hari
(0 Ulasan)
0.0
RohitHooda1

Hi, I have completely read all the descriptions which are mentioned. I have gone through the specific code and already executed the code ,I can share all the specific code with you . Please do a text so that I can sho Lebih banyak

$20 CAD dalam 7 hari
(0 Ulasan)
0.0