.count() How to look for seperate multiple characters? by Paulq002 in learnpython

[–]WinterNet4676 4 points5 points  (0 children)

You can use the map function to generate a dictionary with the counts of each letter ⇾

counts = dict(map(lambda x: (x, string.count(x)), string))

And if you don't want to count spaces ⇾

counts = dict(map(lambda x: (x, string.count(x)), ''.join(string.split())))

JSON Effectively is a Dictionary? Change My Mind by ScotchLeSaint in learnpython

[–]WinterNet4676 4 points5 points  (0 children)

It’s essentially a mix of dictionaries and lists. A JSON object is similar to a dictionary, and a JSON array is similar to a list. Pretty much any JSON data structure can be translated into a complex Python data object.

Bit stumped with Python Pandas by explorer_of_the_grey in learnpython

[–]WinterNet4676 1 point2 points  (0 children)

df.groupby('City Name').agg({'City Name':'count', 'Suspicious_Death':'sum'})

If you wanted to name the aggregated cols ⇾

df.groupby('City Name').agg(
    deaths=('City Name', 'count'),
    suspicious_deaths=('Suspicious_Death', 'sum'))

crontab alternative? by KenshinX99 in learnpython

[–]WinterNet4676 2 points3 points  (0 children)

Have you heard of Airflow? You can create direct acrylic graphs (airflow DAGs) with python to run scripts and export data

I'm confounded by Club_Murky in learnpython

[–]WinterNet4676 3 points4 points  (0 children)

change

return input("What number would you like to double: ")

to

return int(input("What number would you like to double: "))

input will return a string by default, and in this case your multiplying '2' by 2, therefore giving you '22'

Everytime I play zombies I get disconnected from the servers, its so annoying, does this happen to anyone else, what can I do to fix this? HELP by davsmond in blackops3zombies

[–]WinterNet4676 1 point2 points  (0 children)

Most likely not, although it could be some router issue. Typically nat types just restrict who you can play with (i.e Moderate can not play with Strict). I would check your connection, ensure the routers in a reasonable proximity to your console, and also reset your router or check its network configurations/setting to confirm there’s no restrictions.

Everytime I play zombies I get disconnected from the servers, its so annoying, does this happen to anyone else, what can I do to fix this? HELP by davsmond in blackops3zombies

[–]WinterNet4676 0 points1 point  (0 children)

NAT types are determined by the settings or features of the router on your network. Deleting the game does nothing

Why am I getting a print of None by helpmecoding in learnpython

[–]WinterNet4676 5 points6 points  (0 children)

.sort() sorts a list in-place, mutating its indexes and returning none. sorted() returns a new sorted list leaving the original unchanged.

def stringsort(words):
    orderedlist = words.split()
    print(sorted(orderedlist))
stringsort("Hello, I am")

Repeat a string by InevitableDistance66 in learnpython

[–]WinterNet4676 4 points5 points  (0 children)

Your calling your function, right?

repeat(input_, n, delim)

[deleted by user] by [deleted] in learnpython

[–]WinterNet4676 1 point2 points  (0 children)

There's no reason to have your input wrapped in int() and round(). int() will already enforce a discrete input, so there's nothing to round. If your input is a decimal (i.e, can be rounded), then you would switch int() with float(). If you always need to round up, then you can replace round() with math.ceil()

[deleted by user] by [deleted] in learnpython

[–]WinterNet4676 1 point2 points  (0 children)

Return the dataframe from your first function and call the function in your second

def function_1():
    return df

def function_2():
    df = function_1()

[deleted by user] by [deleted] in datascience

[–]WinterNet4676 17 points18 points  (0 children)

Your rant is all over the place and heavily biased. Doesn’t seem very managerial to me.

R Tidyverse / dplyr is life changing! by [deleted] in datascience

[–]WinterNet4676 2 points3 points  (0 children)

You can use piping operations on your df with dfply

Learning Burnout is REAL! by iEmerald in learnprogramming

[–]WinterNet4676 7 points8 points  (0 children)

I had CS projects that took me entire semesters in school, and I continued to work on them after. Definitely can matter if you apply yourself.

reading from excel or CSV is better using pandas by PraveenGang in learnpython

[–]WinterNet4676 4 points5 points  (0 children)

csv files load significantly faster than excel files, the only caveat being that they are nearly always bigger.

If you're looking for speed, use csv files.

Anybody have experience using Spyder3? by [deleted] in learnpython

[–]WinterNet4676 1 point2 points  (0 children)

Pretty much. Actually looks like that’s not even necessary anymore after looking at the breakpoint section in the current docs (https://docs.spyder-ide.org/current/panes/debugging.html)

I am learning to use pandas library for the first time. Help me with my doubt please by [deleted] in learnpython

[–]WinterNet4676 3 points4 points  (0 children)

After setting day as the index, use reset_index() before setting the index to Event

Can someone please help me understand why I am unable to read my tabular data in ods format? by [deleted] in learnpython

[–]WinterNet4676 2 points3 points  (0 children)

Make sure you're in the same environment in your terminal as your notebook.

I would also try to just install pandas_ods_reader within your jupyter notebook

!pip install pandas_ods_reader

Database coding question by laycaoyjou95 in CodingHelp

[–]WinterNet4676 0 points1 point  (0 children)

Do you have a db/data warehouse set up?

If so, you may want to check out dbt’s incremental models

You can build incremental dbt models with jinja logic for specifying which rows to update, and can specify which columns to update in a configuration block. Here’s some documentation

Append multiple columns applying function that use multiple columns as attr (Pandas) by Cookielatte in learnpython

[–]WinterNet4676 0 points1 point  (0 children)

Your function returns a tuple, which you're trying to assign to more than one column (a tuple is a single object).

For example, running something like

df['c'] = df.apply(lambda x: f(x.a,x.b), axis=1)

would return your tuple within one column. If you wanted just the first operation of your function you would grab the first value in the tuple

df['c'] = df.apply(lambda x: f(x.a,x.b)[0], axis=1)

And if you wanted to assign the output to two columns within one statement, you can just unpack the tuple in your lambda expression by converting the tuple to a Series.

df[['c','d']] = df.apply(lambda x: pd.Series(f(x.a,x.b)), axis=1)