Python Forum
Cleaning my code to make it more efficient
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cleaning my code to make it more efficient
#11
It is not really a language thing. It is a forum thing. This is a Python forum, so posters ask technical questions related to Python. The problem with this is most programs fail in the design stage, not the coding stage. I worry that many of the answers provided here fail to solve the real problem, the problem in design that is hidden behind a technical problem. snippsat's earlier response is a technically excellent solution to a problem that I don't think exists.

I have growing confidence that your approach to filtering is wrong, but I have a question about this.
elif not any ([regionas, marketas]):
    filtered_df = df[df["State"].isin(valstija)]
elif valstija and marketas:
    filtered_df = df12[df["State"].isin(valstija) & df12["Marketas"].isin(marketas)]
What is df12, and how does it differ from df? Is df12 the same as df with just the 12 filter columns? If true, does that mean that selecting state and market results in your filtered_df having fewer columns when you filter Market and State than if you only filter Market?

In an earlier post your said this "im using examples from internet". Do you have a link to something that uses your filtering method? I am curious.
BSDevo likes this post
Reply


Messages In This Thread
RE: Cleaning my code to make it more efficient - by deanhystad - Sep-27-2023, 07:48 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  hi need help to make this code work correctly atulkul1985 5 941 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 791 Oct-22-2023, 09:08 PM
Last Post: tronic72
  A more efficient code titanif 2 559 Oct-17-2023, 02:07 PM
Last Post: deanhystad
  how to make bot that sends instagram auto password reset code kraixx 2 1,521 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  Make code non-blocking? Extra 0 1,212 Dec-03-2022, 10:07 PM
Last Post: Extra
  Making a function more efficient CatorCanulis 9 2,036 Oct-06-2022, 07:47 AM
Last Post: DPaul
  Apply textual data cleaning to several CSV files ErcoleL99 0 904 Jul-09-2022, 03:01 PM
Last Post: ErcoleL99
  Make the code shorter quest 2 1,592 Mar-14-2022, 04:28 PM
Last Post: deanhystad
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,884 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  Pyspark - my code works but I want to make it better Kevin 1 1,880 Dec-01-2021, 05:04 AM
Last Post: Kevin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020