|
Thanks for inadvertently bringing f-strings to my attention. I always use str.format() but that seems like a better way to do that...
|
# ¿ Mar 29, 2017 19:33 |
|
|
# ¿ May 8, 2024 03:09 |
|
What's the best way to go through a pandas dataframe and convert all of the values to a different value if they meet a set criteria? I've got a data frame representing grayscale images, where each cell is a value between 0 and 255, and I'd like to just convert this to black and white by changing anything that's not zero into a 1 prior to doing some analysis on it. Is this something I should use .apply for? Forgive me if this is a stupid question, but I'm really new to working with pandas and its slightly different from how a lot of python base types work.
|
# ¿ Jun 8, 2017 19:46 |
|
That... makes sense. I was overcomplicating this. It returns another df rather than changing it in place, right?
|
# ¿ Jun 8, 2017 22:15 |
|
Pandas question! I've got a json file with stupid amounts of nesting that I want to turn into a nice flat datafile. Basically for each record I want to pull just a few features out of each property that are nested two and sometimes three layers deep rather than just flattening the whole thing out and ending up with a ton of extraneous columns. My naive approach was to create an empty dataframe, iterate through the json file and grab things, stick those in a Series and then stick the Series in the dataframe, but I know this can't be the right way to do this. What should I be doing instead?
|
# ¿ Dec 14, 2017 23:00 |
|
I'm going to be getting these json files in batches to process, 100 or so a batch, so I'd like to make this operation reasonably lightweight if I can, but it also doesn't need to be insanely optimized either. I'm okay with running it and then going to get lunch if need be. I think I'm going to basically follow Eela6's approach, make a list of Serieses, and then concatenate it into a DataFrame. That should be good enough. Thanks for your help!
|
# ¿ Dec 16, 2017 00:39 |
|
That seems... not very pythonic?
|
# ¿ Dec 20, 2017 02:56 |
|
|
# ¿ May 8, 2024 03:09 |
|
I wouldn't use it preferentially over the JS IDE if I was doing pure JS but if you're doing a full stack project with Python you can do the frontend stuff in Pycharm and it's actually really seamless and nice.
|
# ¿ Jul 2, 2018 00:16 |