Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: groupby cast to int where possible
Post: RE: groupby cast to int where possible

In case it helps anyone, I found a workaround for my issue. Basically, I try to cast the column to integers, using errors="coerce". If it can't be interpreted as a number, it converts it to nan. I can...
mikisDeWitte General Coding Help 2 449 Jul-08-2021, 11:49 AM
    Thread: groupby cast to int where possible
Post: groupby cast to int where possible

Hello, I need to create a nested dictionary like so: d= {"ftsg2a_co422": {1: 'visited or contacted', 0: 'not visited not contacted'}} this dictionary then goes to a function that sets value labels t...
mikisDeWitte General Coding Help 2 449 Jul-01-2021, 01:40 PM
    Thread: pyreadstat write_sav inefficient
Post: RE: pyreadstat write_sav inefficient

(Jun-21-2021, 08:38 AM)buran Wrote: have a look at https://stackoverflow.com/questions/4717...nwrite-sav Also you can try to pass compress=True and create zsav file. Thanks, that seems to be indeed ...
mikisDeWitte General Coding Help 2 532 Jun-21-2021, 09:49 AM
    Thread: pyreadstat write_sav inefficient
Post: pyreadstat write_sav inefficient

Hello, My colleagues work mostly in SPSS, so for their sake i export my dataframes to SPSS using the pyreadstat module (installed via conda, version 1.1.2). Everything works fine, except that my expo...
mikisDeWitte General Coding Help 2 532 Jun-21-2021, 08:32 AM
    Thread: apply(pd.Series) until no more array
Post: apply(pd.Series) until no more array

Update: we found it eventually. Using the same link, a more recent answer helped us out a lot: df2 = pd.json_normalize(df['Pollutant Levels'])Hello, We extract data from a mongoDB using python. When...
mikisDeWitte Data Science 1 850 Apr-14-2021, 02:27 PM
    Thread: dataframe groupby with totals for certain fields
Post: RE: dataframe groupby with totals for certain fiel...

(Oct-23-2020, 05:41 AM)scidam Wrote: Quote:, and I was told that if you're looping then most of the times you're probably doing it wrong In this case loop doesn't apply to all dataframe, you just i...
mikisDeWitte Data Science 4 958 Oct-23-2020, 08:13 AM
    Thread: dataframe groupby with totals for certain fields
Post: RE: dataframe groupby with totals for certain fiel...

(Oct-19-2020, 12:21 AM)scidam Wrote: Your for-loop iterates over two items (or a few number of columns)... I don't understand why it is expensive (probably, copying and concatenating huge df's are e...
mikisDeWitte Data Science 4 958 Oct-22-2020, 11:32 AM
    Thread: dataframe groupby with totals for certain fields
Post: dataframe groupby with totals for certain fields

Hello, I am frequently required to calculate stuff for a number of dataframe columns, but with totals included. I know I can ignore a specific dimension using the transform function (https://stackove...
mikisDeWitte Data Science 4 958 Oct-16-2020, 11:09 AM

User Panel Messages

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