workspace
stringclasses 1
value | channel
stringclasses 1
value | sentences
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
| sentence_id
stringlengths 44
53
| timestamp
float64 1.5B
1.56B
| __index_level_0__
int64 0
106k
|
---|---|---|---|---|---|---|---|
pythondev
|
help
|
<@Walton> if you have a choice, i found the ldap3 package to be much easier to work with
|
2019-05-09T18:15:27.084400
|
Doug
|
pythondev_help_Doug_2019-05-09T18:15:27.084400
| 1,557,425,727.0844 | 22,821 |
pythondev
|
help
|
I will look into that, thank you
|
2019-05-09T20:06:55.089300
|
Walton
|
pythondev_help_Walton_2019-05-09T20:06:55.089300
| 1,557,432,415.0893 | 22,822 |
pythondev
|
help
|
Hey guys
|
2019-05-09T20:52:00.089600
|
Cristopher
|
pythondev_help_Cristopher_2019-05-09T20:52:00.089600
| 1,557,435,120.0896 | 22,823 |
pythondev
|
help
|
I am learning Django
|
2019-05-09T20:52:04.090000
|
Cristopher
|
pythondev_help_Cristopher_2019-05-09T20:52:04.090000
| 1,557,435,124.09 | 22,824 |
pythondev
|
help
|
and stuck in some error which I can't figure it out why! I am new to django and python
|
2019-05-09T20:52:31.090600
|
Cristopher
|
pythondev_help_Cristopher_2019-05-09T20:52:31.090600
| 1,557,435,151.0906 | 22,825 |
pythondev
|
help
|
This is my error in server! if anyone can help that would be great
|
2019-05-09T20:53:45.090700
|
Cristopher
|
pythondev_help_Cristopher_2019-05-09T20:53:45.090700
| 1,557,435,225.0907 | 22,826 |
pythondev
|
help
|
the error is fairly descriptive, <@Cristopher>
|
2019-05-09T20:54:56.091900
|
Hiroko
|
pythondev_help_Hiroko_2019-05-09T20:54:56.091900
| 1,557,435,296.0919 | 22,827 |
pythondev
|
help
|
`templates` in your view should be `template_name`
|
2019-05-09T20:55:07.092200
|
Hiroko
|
pythondev_help_Hiroko_2019-05-09T20:55:07.092200
| 1,557,435,307.0922 | 22,828 |
pythondev
|
help
|
so should I write as templates_names?
|
2019-05-09T20:56:13.092600
|
Cristopher
|
pythondev_help_Cristopher_2019-05-09T20:56:13.092600
| 1,557,435,373.0926 | 22,829 |
pythondev
|
help
|
yes
|
2019-05-09T20:57:08.093000
|
Hiroko
|
pythondev_help_Hiroko_2019-05-09T20:57:08.093000
| 1,557,435,428.093 | 22,830 |
pythondev
|
help
|
anyone familiar with `pydub`?
|
2019-05-09T21:04:21.093400
|
Jada
|
pythondev_help_Jada_2019-05-09T21:04:21.093400
| 1,557,435,861.0934 | 22,831 |
pythondev
|
help
|
I'd like to log what a pydub method does as it's working - I have a large file and the process is taking a while
|
2019-05-09T21:04:51.094000
|
Jada
|
pythondev_help_Jada_2019-05-09T21:04:51.094000
| 1,557,435,891.094 | 22,832 |
pythondev
|
help
|
can't tell if it's working as expected
|
2019-05-09T21:05:00.094300
|
Jada
|
pythondev_help_Jada_2019-05-09T21:05:00.094300
| 1,557,435,900.0943 | 22,833 |
pythondev
|
help
|
show me the broken case if possible
|
2019-05-09T22:06:02.094700
|
Bertram
|
pythondev_help_Bertram_2019-05-09T22:06:02.094700
| 1,557,439,562.0947 | 22,834 |
pythondev
|
help
|
Why not profile your code?
|
2019-05-09T22:31:41.095200
|
Shan
|
pythondev_help_Shan_2019-05-09T22:31:41.095200
| 1,557,441,101.0952 | 22,835 |
pythondev
|
help
|
For example:
```>>> a = [1, 1, 1, 2, 3, 4]
>>> moveOnetoTail(a, cmp)
[4, 3, 2, 1, 1, 1] # expected [2, 3, 4, 1, 1, 1]```
|
2019-05-10T00:15:59.096100
|
Sasha
|
pythondev_help_Sasha_2019-05-10T00:15:59.096100
| 1,557,447,359.0961 | 22,836 |
pythondev
|
help
|
Hi there
|
2019-05-10T00:49:36.096600
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:49:36.096600
| 1,557,449,376.0966 | 22,837 |
pythondev
|
help
|
I have a="Test" b="abc"
|
2019-05-10T00:49:38.096800
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:49:38.096800
| 1,557,449,378.0968 | 22,838 |
pythondev
|
help
|
"Taebsct" is the result i want
|
2019-05-10T00:49:47.097200
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:49:47.097200
| 1,557,449,387.0972 | 22,839 |
pythondev
|
help
|
how can i print that alternatively
|
2019-05-10T00:49:51.097400
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:49:51.097400
| 1,557,449,391.0974 | 22,840 |
pythondev
|
help
|
should i use enum or something here?
could some one help me with a snippet?
|
2019-05-10T00:51:50.097800
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:51:50.097800
| 1,557,449,510.0978 | 22,841 |
pythondev
|
help
|
```def mergeStrings(a, b):
la = len(a)
lb = len(b)
newString = []
if la == lb:
for i,j in zip(la,lb):
newString.append(la)
newString.append(lb)
return newString```
|
2019-05-10T00:57:33.098100
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:57:33.098100
| 1,557,449,853.0981 | 22,842 |
pythondev
|
help
|
this is my attempt
|
2019-05-10T00:57:35.098300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T00:57:35.098300
| 1,557,449,855.0983 | 22,843 |
pythondev
|
help
|
Cool, you're close. You're using the length variables `la` and `lb` in a couple of places where you want to either use the strings `a` and `b` or the characters `i` and `j`, though.
|
2019-05-10T01:00:23.099700
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:00:23.099700
| 1,557,450,023.0997 | 22,844 |
pythondev
|
help
|
```def mergeStrings(a, b):
la = len(a)
lb = len(b)
newString = []
if la ==lb:
for i,j in zip(a,b):
newString.append(i)
newString.append(j)
outputString = ''.join(newString)
return outputString
```
|
2019-05-10T01:02:33.100000
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:02:33.100000
| 1,557,450,153.1 | 22,845 |
pythondev
|
help
|
yes I am able to do it
|
2019-05-10T01:02:36.100200
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:02:36.100200
| 1,557,450,156.1002 | 22,846 |
pythondev
|
help
|
but thing here is
|
2019-05-10T01:02:40.100500
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:02:40.100500
| 1,557,450,160.1005 | 22,847 |
pythondev
|
help
|
lets say if a='123' b='abcdef'
now i want the result to have '1a2b3cdef'
|
2019-05-10T01:03:03.101100
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:03:03.101100
| 1,557,450,183.1011 | 22,848 |
pythondev
|
help
|
how can i do that <@Sasha>
|
2019-05-10T01:03:09.101300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:03:09.101300
| 1,557,450,189.1013 | 22,849 |
pythondev
|
help
|
The easiest change would be to use `itertools.zip_longest()` instead of `zip()`. You can tell it to fill in the missing values with an empty string.
|
2019-05-10T01:05:03.102000
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:05:03.102000
| 1,557,450,303.102 | 22,850 |
pythondev
|
help
|
could you give me a snippet
|
2019-05-10T01:05:15.102200
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:05:15.102200
| 1,557,450,315.1022 | 22,851 |
pythondev
|
help
|
<https://docs.python.org/3/library/itertools.html#itertools.zip_longest>
|
2019-05-10T01:06:48.102400
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:06:48.102400
| 1,557,450,408.1024 | 22,852 |
pythondev
|
help
|
<@Sasha> are you thinking something like this?
''.join(''.join(x) for x in itertools.zip_longest(a, b, fillvalue=''))
|
2019-05-10T01:10:05.102800
|
Mildred
|
pythondev_help_Mildred_2019-05-10T01:10:05.102800
| 1,557,450,605.1028 | 22,853 |
pythondev
|
help
|
Yep. I was assuming that <@Lanelle> could use his original `append` logic, but that double `join` should also work.
|
2019-05-10T01:12:37.103900
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:12:37.103900
| 1,557,450,757.1039 | 22,854 |
pythondev
|
help
|
<@Sasha> I get this error though ```AttributeError: 'module' object has no attribute 'zip_longest'```
|
2019-05-10T01:17:32.104400
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T01:17:32.104400
| 1,557,451,052.1044 | 22,855 |
pythondev
|
help
|
did you import itertools?
|
2019-05-10T01:17:53.104700
|
Mildred
|
pythondev_help_Mildred_2019-05-10T01:17:53.104700
| 1,557,451,073.1047 | 22,856 |
pythondev
|
help
|
What Python version are you running? It might not be in Py2.
|
2019-05-10T01:18:17.105100
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:18:17.105100
| 1,557,451,097.1051 | 22,857 |
pythondev
|
help
|
Ah, it's called `izip_longest()` in Py2.
|
2019-05-10T01:20:03.105500
|
Sasha
|
pythondev_help_Sasha_2019-05-10T01:20:03.105500
| 1,557,451,203.1055 | 22,858 |
pythondev
|
help
|
or `''.join(itertools.chain.from_iterable(itertools.zip_longest(a,b, fillvalue='')))` :parrot:
|
2019-05-10T01:23:03.105600
|
Raguel
|
pythondev_help_Raguel_2019-05-10T01:23:03.105600
| 1,557,451,383.1056 | 22,859 |
pythondev
|
help
|
Hi. I have a problem. In the model `FieldType`, I am trying to create a model that gives the user access to any of Django's field types (text, number, string) so that they can create their own field. What would I put at line #6 so that I can do that?
|
2019-05-10T01:28:18.106000
|
Jamey
|
pythondev_help_Jamey_2019-05-10T01:28:18.106000
| 1,557,451,698.106 | 22,860 |
pythondev
|
help
|
because im a little slow, ive only just discovered this:
<http://pythontutor.com/visualize.html>
|
2019-05-10T01:34:01.106900
|
Mildred
|
pythondev_help_Mildred_2019-05-10T01:34:01.106900
| 1,557,452,041.1069 | 22,861 |
pythondev
|
help
|
Thanks for sharing <@Mildred> :taco: ! I found this 5 months ago, never used and forgot about it
|
2019-05-10T01:38:11.107800
|
Conchita
|
pythondev_help_Conchita_2019-05-10T01:38:11.107800
| 1,557,452,291.1078 | 22,862 |
pythondev
|
help
|
Will run it agains some of my scripts
|
2019-05-10T01:38:18.108100
|
Conchita
|
pythondev_help_Conchita_2019-05-10T01:38:18.108100
| 1,557,452,298.1081 | 22,863 |
pythondev
|
help
|
Super cool
|
2019-05-10T01:38:20.108300
|
Conchita
|
pythondev_help_Conchita_2019-05-10T01:38:20.108300
| 1,557,452,300.1083 | 22,864 |
pythondev
|
help
|
i discovered it yesterday in a talk python to me podcast from 2016?.... yeah... bit behind :stuck_out_tongue:
|
2019-05-10T01:39:32.109000
|
Mildred
|
pythondev_help_Mildred_2019-05-10T01:39:32.109000
| 1,557,452,372.109 | 22,865 |
pythondev
|
help
|
<@Mildred> when we discover tools when we need them, we're not late... we're just on time :wink:
|
2019-05-10T01:41:06.109800
|
Jamey
|
pythondev_help_Jamey_2019-05-10T01:41:06.109800
| 1,557,452,466.1098 | 22,866 |
pythondev
|
help
|
that led me down a path to find the most optimal fizzbuzz
|
2019-05-10T01:56:59.110600
|
Shan
|
pythondev_help_Shan_2019-05-10T01:56:59.110600
| 1,557,453,419.1106 | 22,867 |
pythondev
|
help
|
```i=1
while i<101:print("Fizz"*(i%3<1)+(i%5<1)*"Buzz"or i);i+=1
```
|
2019-05-10T01:57:04.110800
|
Shan
|
pythondev_help_Shan_2019-05-10T01:57:04.110800
| 1,557,453,424.1108 | 22,868 |
pythondev
|
help
|
i really love the itertools infinite sequences solution to fizzbuzz... if you dont know what a while loop is then that should be one of the most intuitive ways to code it
|
2019-05-10T02:10:05.112200
|
Leida
|
pythondev_help_Leida_2019-05-10T02:10:05.112200
| 1,557,454,205.1122 | 22,869 |
pythondev
|
help
|
something like this ```import itertools
def fizzbuzz():
fizz = itertools.cycle([""] * 2 + ["fizz"])
buzz = itertools.cycle([""] * 4 + ["buzz"])
for i in range(1, 101):
print next(fizz) + next(buzz) or i```
|
2019-05-10T02:12:25.112500
|
Leida
|
pythondev_help_Leida_2019-05-10T02:12:25.112500
| 1,557,454,345.1125 | 22,870 |
pythondev
|
help
|
only replace the for loop with real number generator
|
2019-05-10T02:13:15.112900
|
Leida
|
pythondev_help_Leida_2019-05-10T02:13:15.112900
| 1,557,454,395.1129 | 22,871 |
pythondev
|
help
|
That's clever, but it's also fragile, since there's no inherent connection to `i` in the iterator logic. Change the loop to start from 2 instead of 1 and it all falls apart.
|
2019-05-10T02:15:08.114000
|
Sasha
|
pythondev_help_Sasha_2019-05-10T02:15:08.114000
| 1,557,454,508.114 | 22,872 |
pythondev
|
help
|
this is a version of what i meant i found on google with a quick search, the real one has 3 infinite sequences and merges em into a generator
|
2019-05-10T02:16:08.114800
|
Leida
|
pythondev_help_Leida_2019-05-10T02:16:08.114800
| 1,557,454,568.1148 | 22,873 |
pythondev
|
help
|
think it was in a hettinger talk, but i dont really remember
|
2019-05-10T02:16:55.115200
|
Leida
|
pythondev_help_Leida_2019-05-10T02:16:55.115200
| 1,557,454,615.1152 | 22,874 |
pythondev
|
help
|
i dont like the magic numbers in there either
|
2019-05-10T02:17:27.115500
|
Leida
|
pythondev_help_Leida_2019-05-10T02:17:27.115500
| 1,557,454,647.1155 | 22,875 |
pythondev
|
help
|
`[""] * x` does the trick but it can sorta hide the idea unless you know how that multiplication works
|
2019-05-10T02:18:40.116800
|
Leida
|
pythondev_help_Leida_2019-05-10T02:18:40.116800
| 1,557,454,720.1168 | 22,876 |
pythondev
|
help
|
makes you look at the `*` and `+` instead of the core idea
|
2019-05-10T02:19:21.117500
|
Leida
|
pythondev_help_Leida_2019-05-10T02:19:21.117500
| 1,557,454,761.1175 | 22,877 |
pythondev
|
help
|
```10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] "GET /a.gif HTTP/1.0" 200 234```
this is a string and i m converting to a list
|
2019-05-10T02:36:22.118000
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:36:22.118000
| 1,557,455,782.118 | 22,878 |
pythondev
|
help
|
any better way to find the ip address?
|
2019-05-10T02:36:29.118300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:36:29.118300
| 1,557,455,789.1183 | 22,879 |
pythondev
|
help
|
idk if its any good but my brain jumps to find first ` -` and all before that is the ip
|
2019-05-10T02:37:55.119300
|
Leida
|
pythondev_help_Leida_2019-05-10T02:37:55.119300
| 1,557,455,875.1193 | 22,880 |
pythondev
|
help
|
``` lines = ["10.0.0.1 - frank [10/Dec/2000:12:34:56 -0500] \"GET /a.gif HTTP/1.0\" 200 234",
"10.0.0.1 - frank [10/Dec/2000:12:34:57 -0500] \"GET /b.gif HTTP/1.0\" 200 234",
"10.0.0.2 - nancy [10/Dec/2000:12:34:58 -0500] \"GET /c.gif HTTP/1.0\" 200 234"]```
|
2019-05-10T02:41:36.119900
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:41:36.119900
| 1,557,456,096.1199 | 22,881 |
pythondev
|
help
|
```
end_of_ip = your_string.find(' -')
ip = your_string[:end_of_ip]```
|
2019-05-10T02:42:17.120600
|
Leida
|
pythondev_help_Leida_2019-05-10T02:42:17.120600
| 1,557,456,137.1206 | 22,882 |
pythondev
|
help
|
wrap the previous into `for line in lines:` and do what you need with the ip
|
2019-05-10T02:43:32.121600
|
Leida
|
pythondev_help_Leida_2019-05-10T02:43:32.121600
| 1,557,456,212.1216 | 22,883 |
pythondev
|
help
|
where `your_string` is `line`
|
2019-05-10T02:44:00.122000
|
Leida
|
pythondev_help_Leida_2019-05-10T02:44:00.122000
| 1,557,456,240.122 | 22,884 |
pythondev
|
help
|
that is all assuming you only need the IP, if you need to convert it to a data structure then that wont do
|
2019-05-10T02:45:46.122500
|
Leida
|
pythondev_help_Leida_2019-05-10T02:45:46.122500
| 1,557,456,346.1225 | 22,885 |
pythondev
|
help
|
```
ip, _ = line.split(" ", 1) # maxsplit = 1
```
|
2019-05-10T02:47:16.123200
|
Guillermina
|
pythondev_help_Guillermina_2019-05-10T02:47:16.123200
| 1,557,456,436.1232 | 22,886 |
pythondev
|
help
|
cool.. <@Leida> now since 10.0.0.1 is the repeated maximum, i have to print that
|
2019-05-10T02:48:59.123900
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:48:59.123900
| 1,557,456,539.1239 | 22,887 |
pythondev
|
help
|
i have appended the ips to an empty list
|
2019-05-10T02:49:06.124200
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:49:06.124200
| 1,557,456,546.1242 | 22,888 |
pythondev
|
help
|
how do i proceed now?
|
2019-05-10T02:51:29.124500
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:51:29.124500
| 1,557,456,689.1245 | 22,889 |
pythondev
|
help
|
you mean to find the IP that appears the most?
|
2019-05-10T02:51:39.124800
|
Leida
|
pythondev_help_Leida_2019-05-10T02:51:39.124800
| 1,557,456,699.1248 | 22,890 |
pythondev
|
help
|
yes
|
2019-05-10T02:51:46.125100
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:51:46.125100
| 1,557,456,706.1251 | 22,891 |
pythondev
|
help
|
quick google `max(k for k,v in Counter(mylist).items() if v>1)`
|
2019-05-10T02:53:02.125600
|
Leida
|
pythondev_help_Leida_2019-05-10T02:53:02.125600
| 1,557,456,782.1256 | 22,892 |
pythondev
|
help
|
should i import collections?
|
2019-05-10T02:54:28.126000
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:54:28.126000
| 1,557,456,868.126 | 22,893 |
pythondev
|
help
|
```>>> max(k for k,v in collections.Counter(l).items if v>1)
Traceback (most recent call last):
File "<ipython-input-14-8c63f5f2b47b>", line 1, in <module>
max(k for k,v in collections.Counter(l).items if v>1)
TypeError: 'builtin_function_or_method' object is not iterable```
|
2019-05-10T02:54:37.126300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:54:37.126300
| 1,557,456,877.1263 | 22,894 |
pythondev
|
help
|
<https://stackoverflow.com/questions/11255035/get-max-duplicate-item-in-list/11256412#11256412> heres a whole list of em and timing the speed too
|
2019-05-10T02:54:52.126700
|
Leida
|
pythondev_help_Leida_2019-05-10T02:54:52.126700
| 1,557,456,892.1267 | 22,895 |
pythondev
|
help
|
That example won't quite work, but `Counter` has a `most_common()` method.
|
2019-05-10T02:55:07.126900
|
Sasha
|
pythondev_help_Sasha_2019-05-10T02:55:07.126900
| 1,557,456,907.1269 | 22,896 |
pythondev
|
help
|
or `pd.Series(list).value_counts()[[0]]`
|
2019-05-10T02:55:37.127100
|
Raguel
|
pythondev_help_Raguel_2019-05-10T02:55:37.127100
| 1,557,456,937.1271 | 22,897 |
pythondev
|
help
|
<@Raguel> what is pd?
|
2019-05-10T02:55:53.127300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:55:53.127300
| 1,557,456,953.1273 | 22,898 |
pythondev
|
help
|
pandas as pd
|
2019-05-10T02:55:58.127500
|
Raguel
|
pythondev_help_Raguel_2019-05-10T02:55:58.127500
| 1,557,456,958.1275 | 22,899 |
pythondev
|
help
|
pandas would be bit of a dependency no?
|
2019-05-10T02:55:59.127700
|
Leida
|
pythondev_help_Leida_2019-05-10T02:55:59.127700
| 1,557,456,959.1277 | 22,900 |
pythondev
|
help
|
true, it would be
|
2019-05-10T02:56:08.127900
|
Raguel
|
pythondev_help_Raguel_2019-05-10T02:56:08.127900
| 1,557,456,968.1279 | 22,901 |
pythondev
|
help
|
cant we do it without panda
|
2019-05-10T02:56:17.128100
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:56:17.128100
| 1,557,456,977.1281 | 22,902 |
pythondev
|
help
|
`most_common()` is probably a good idea, the python library solutions tend to be rather well thought through
|
2019-05-10T02:56:49.128300
|
Leida
|
pythondev_help_Leida_2019-05-10T02:56:49.128300
| 1,557,457,009.1283 | 22,903 |
pythondev
|
help
|
where is the snippet for most_common?
|
2019-05-10T02:57:01.128500
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T02:57:01.128500
| 1,557,457,021.1285 | 22,904 |
pythondev
|
help
|
<https://docs.python.org/2/library/collections.html#collections.Counter.most_common>
|
2019-05-10T02:57:26.128700
|
Leida
|
pythondev_help_Leida_2019-05-10T02:57:26.128700
| 1,557,457,046.1287 | 22,905 |
pythondev
|
help
|
should work as `Counter(IPs).most_common(1)`
|
2019-05-10T02:58:28.128900
|
Leida
|
pythondev_help_Leida_2019-05-10T02:58:28.128900
| 1,557,457,108.1289 | 22,906 |
pythondev
|
help
|
and yes you will need to import the relevant library which is `collections`
|
2019-05-10T02:59:12.129100
|
Leida
|
pythondev_help_Leida_2019-05-10T02:59:12.129100
| 1,557,457,152.1291 | 22,907 |
pythondev
|
help
|
I dont see most_common
|
2019-05-10T03:00:17.129300
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T03:00:17.129300
| 1,557,457,217.1293 | 22,908 |
pythondev
|
help
|
<@Leida> any other simpler way of doing this?
|
2019-05-10T03:01:18.129500
|
Lanelle
|
pythondev_help_Lanelle_2019-05-10T03:01:18.129500
| 1,557,457,278.1295 | 22,909 |
pythondev
|
help
|
The snippet that <@Leida> posted just needs a little tweak: `max((v,k) for k,v in Counter(mylist).items())`.
|
2019-05-10T03:04:13.129700
|
Sasha
|
pythondev_help_Sasha_2019-05-10T03:04:13.129700
| 1,557,457,453.1297 | 22,910 |
pythondev
|
help
|
```
from collections import Counter
# get your lines from somewhere
ip_list = []
for line in lines:
ip, _ = line.split(" ", 1)
ip_list.append(ip)
most_common_ip = Counter(ip_list).most_common(1)
```
should be alright?
|
2019-05-10T03:07:13.130000
|
Leida
|
pythondev_help_Leida_2019-05-10T03:07:13.130000
| 1,557,457,633.13 | 22,911 |
pythondev
|
help
|
Note that this problem is "return the maximum number that has at least one duplicate", rather than "return the value which has the most duplicates".
|
2019-05-10T03:09:29.130200
|
Sasha
|
pythondev_help_Sasha_2019-05-10T03:09:29.130200
| 1,557,457,769.1302 | 22,912 |
pythondev
|
help
|
<https://repl.it/repls/SeagreenRustyParallelcomputing> runs there atleast. The version with `max` still has `Counter` in which needs importing.
|
2019-05-10T03:10:18.130400
|
Leida
|
pythondev_help_Leida_2019-05-10T03:10:18.130400
| 1,557,457,818.1304 | 22,913 |
pythondev
|
help
|
found this another method: `max(set(a), key=a.count)`
|
2019-05-10T03:12:05.130700
|
Raguel
|
pythondev_help_Raguel_2019-05-10T03:12:05.130700
| 1,557,457,925.1307 | 22,914 |
pythondev
|
help
|
right, hence the `>1`
|
2019-05-10T03:16:08.130900
|
Leida
|
pythondev_help_Leida_2019-05-10T03:16:08.130900
| 1,557,458,168.1309 | 22,915 |
pythondev
|
help
|
Wow. That's clever as hell, even if it's O(n^2).
|
2019-05-10T03:20:20.131100
|
Sasha
|
pythondev_help_Sasha_2019-05-10T03:20:20.131100
| 1,557,458,420.1311 | 22,916 |
pythondev
|
help
|
Yeah, but it's a different problem than houami wants to solve.
|
2019-05-10T03:21:22.131300
|
Sasha
|
pythondev_help_Sasha_2019-05-10T03:21:22.131300
| 1,557,458,482.1313 | 22,917 |
pythondev
|
help
|
Yeah, I couldn’t have come up with that — I just googled finding mode of a list, and stumbled upon that. How do people come up with such solutions :sob:
|
2019-05-10T03:23:13.131500
|
Raguel
|
pythondev_help_Raguel_2019-05-10T03:23:13.131500
| 1,557,458,593.1315 | 22,918 |
pythondev
|
help
|
it could be efficient to store the ips in a c++ type multi hash set or somehow in a regular set... that way you wouldnt have to waste much effort in the search later
|
2019-05-10T03:23:54.131700
|
Leida
|
pythondev_help_Leida_2019-05-10T03:23:54.131700
| 1,557,458,634.1317 | 22,919 |
pythondev
|
help
|
only i dont know the python implementations and im not sure how the set would work...
|
2019-05-10T03:24:48.131900
|
Leida
|
pythondev_help_Leida_2019-05-10T03:24:48.131900
| 1,557,458,688.1319 | 22,920 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.