Explore all Construction related open source software, libraries, packages, source code, cloud functions and APIs.

Construction covers the processes involved in delivering buildings, infrastructure and industrial facilities, and associated activities through to the end of their life. It typically starts with planning, financing, and design, and continues until the asset is built and ready for use; construction also covers repairs and maintenance work, any works to expand, extend and improve the asset, and its eventual demolition, dismantling or decommissioning.

These software components cover functions across Architectural Design, Building, Plumbing, Carpentry, Interior, HVAC areas.

Popular New Releases in Construction

plugwise-beta

More improvements

FAST

Release v0.0.7

UI24RBridge

v0.7.3

ad-alexasmarttalkingthermostat

Power Backup Guard, Notifications Schedule (breaking changes, see docs)

homebridge-garage-door-wsensor

2.0.4

Popular Libraries in Construction

Justified-Gallery

by miromannino doticonjavascriptdoticon

star image 1470 doticonMIT

Javascript library to help creating high quality justified galleries of images. Used by thousands of websites as well as the photography community 500px.

python-elevator-challenge

by mshang doticonpythondoticon

star image 1373 doticonMIT

So You Think You Can Program An Elevator

homebridge-xiaomi-air-purifier3

by rgavril doticonjavascriptdoticon

star image 39 doticon

Homebridge plugin for controlling Xiaomi Air Purifier 3/3H

akvo-rsr

by akvo doticonpythondoticon

star image 33 doticonAGPL-3.0

Akvo Really Simple Reporting

Parquet

by clarkx doticonpythondoticon

star image 32 doticon

Floor board generator add-on for Blender

sample-elevator-control-system

by joeblau doticonjavadoticon

star image 31 doticon

JAVA Elevator Control System (3 Hour Challenge)

com.fibaro

by athombv doticonjavascriptdoticon

star image 31 doticonGPL-3.0

Fibaro + Homey

ElevatorAllocation

by lettergram doticonpythondoticon

star image 29 doticon

Elevator Allocation Algorithm for austingwalters.com

Face-recognition-home-door-lock-system

by ravirajsinh45 doticonpythondoticon

star image 25 doticon

Made Face recognition door lock with Raspberry Pi and other sensors.

Trending New libraries in Construction

homebridge-xiaomi-air-purifier3

by rgavril doticonjavascriptdoticon

star image 39 doticon

Homebridge plugin for controlling Xiaomi Air Purifier 3/3H

Face-recognition-home-door-lock-system

by ravirajsinh45 doticonpythondoticon

star image 25 doticon

Made Face recognition door lock with Raspberry Pi and other sensors.

plugwise-beta

by plugwise doticonpythondoticon

star image 22 doticonMIT

Custom-component / development version of the Plugwise Home Assistant platform

win_det_heatmaps

by lck1201 doticonpythondoticon

star image 18 doticonMIT

Window Detection in Facade Using Heatmaps Fushion

caad4rhino

by caadxyz doticonpythondoticon

star image 13 doticonLGPL-3.0

Caad4Rhino is a python package whose purpose is to provide computer aided architectural design tools in rhino 3d software

homebridge-dummy-garage

by rasod doticonjavascriptdoticon

star image 10 doticon

Dummy Garage Opener for Homebridge

unity-gameobject-brush

by acoppes doticoncsharpdoticon

star image 8 doticonMIT

Unity's Editor GameObjects Paint Tool for 2D Games. It contains both a custom window for objects palette + a customizable brush for paining.

ad-alexasmarttalkingthermostat

by UbhiTS doticonpythondoticon

star image 7 doticonApache-2.0

Set temp limits, enforce fan modes, door/window and daily shut-off, and air cycling makes your thermostat a genius with a voice using your Smart Speaker! Please :star: if you like the app :)

Top Authors in Construction

1

PolyCortex

1 Libraries

star icon15

2

MatthewInch

1 Libraries

star icon14

3

joeblau

1 Libraries

star icon31

4

ggottwald

1 Libraries

star icon4

5

furti

1 Libraries

star icon15

6

lettergram

1 Libraries

star icon29

7

gnsmrky

1 Libraries

star icon9

8

qqnc

1 Libraries

star icon13

9

JestonBlu

1 Libraries

star icon10

10

professorxin

1 Libraries

star icon15

1

1 Libraries

star icon15

2

1 Libraries

star icon14

3

1 Libraries

star icon31

4

1 Libraries

star icon4

5

1 Libraries

star icon15

6

1 Libraries

star icon29

7

1 Libraries

star icon9

8

1 Libraries

star icon13

9

1 Libraries

star icon10

10

1 Libraries

star icon15

Trending Kits in Construction

No Trending Kits are available at this moment for Construction

Trending Discussions on Construction

Apparent bug in clang when assigning a r value containing a `std::string` from a constructor

Raku Ambiguous call to infix(Hyper: Dan::Series, Int)

how to use release branch to increment version using setuptools_scm?

Is Shannon-Fano coding ambiguous?

std::vector move assignment vs construction: why is the state of 'other' not consistent?

C++ - Why does aggregate initialization not work with template struct

I have a dataset in which i have two columns with time in it but the dat

Is there any workaround for passing a function template as a template parameter?

Thread safety of std::cout insertion operator

Why doesn't std::string have a constructor that directly takes std::string_view?

QUESTION

Apparent bug in clang when assigning a r value containing a `std::string` from a constructor

Asked 2022-Apr-15 at 19:32

While testing handling of const object members I ran into this apparent bug in clang. The code works in msvc and gcc. However, the bug only appears with non-consts which is certainly the most common use. Am I doing something wrong or is this a real bug?

https://godbolt.org/z/Gbxjo19Ez

1#include <string>
2#include <memory>
3
4struct A
5{
6    // const std::string s; // Oddly, declaring s const compiles
7    std::string s;
8    constexpr A() = default;
9    constexpr A(A&& rh) = default;
10    constexpr A& operator=(A&& rh) noexcept
11    {
12        std::destroy_at(this);
13        std::construct_at(this, std::move(rh));
14        return *this;
15    }
16};
17
18constexpr int foo()
19{
20    A i0{};    // call ctor
21    // Fails with clang. OK msvc, gcc
22    // construction of subobject of member '_M_local_buf' of union with no active member is not allowed in a constant expression { return ::new((void*)__location) _Tp(std::forward<_Args>(__args)...); }
23    i0 = A{};  // call assign rctor
24    return 42;
25}
26
27int main() {
28    constexpr int i = foo();
29    return i;
30}
31

For those interested, here's the full version that turns const objects into first class citizens (usable in vectors, sorting, and such). I really dislike adding getters to maintain immutability.

https://godbolt.org/z/hx7f9Krn8

ANSWER

Answered 2022-Apr-15 at 19:32

Your game of "construct a new object in place of the old one" is the problem.

  1. It is completely forbidden if the object is const or contains any const member subobjects.

due to the following rule in [basic.life] (note that a rewrite1 of this rule is proposed in post-C++17 drafts)

If, after the lifetime of an object has ended and before the storage which the object occupied is reused or released, a new object is created at the storage location which the original object occupied, a pointer that pointed to the original object, a reference that referred to the original object, or the name of the original object will automatically refer to the new object and, once the lifetime of the new object has started, can be used to manipulate the new object, if:

  • the storage for the new object exactly overlays the storage location which the original object occupied,

and

  • the new object is of the same type as the original object (ignoring the top-level cv-qualifiers)

and

  • the type of the original object is not const-qualified, and, if a class type, does not contain any non-static data member whose type is const-qualified or a reference type

and

  • the original object was a most derived object of type T and the new object is a most derived object of type T (that is, they are not base class subobjects).

You have to abide by this rule for the purposes both of return *this; and also the implicit destructor call.

  1. It also doesn't work during constexpr evaluation.

... this one is specific to the fact that std::string small-string optimization may be implemented using a union, and changing an active union member has been forbidden during constexpr evaluation, although this rule too seems to have changed post-C++17.


1 I consider said change to be misguided (it doesn't even permit the pattern it was supposed to fix) and break legitimate coding patterns. While it's true that a pointer to const-qualified object only made my view readonly and did not let me assume that the object wasn't being changed by someone else holding a pointer/reference that wasn't so qualified, in the past if I was given a pointer (qualified or not) to an object with a const member, I was assured that no one was changing that member and I (or my optimizing compiler) could safely use a cached copy of that member (or data derived from that member value, such as a hash or a comparison result).

Apparently this is no longer true.

While changing the language rule may automatically remove all compiler optimizations that would have assumed immutability of a const member, there's no automatic patch to user-written code which was correct and bug-free under the old rules, for example std::map and std::unordered_map code using std::pair<const Key, Value>. Yet the DR doesn't appear to have considered this as a breaking change...

I was asked for a code snippet that illustrates a behavior change of existing valid code, here it is. This code was formerly illegal, under the new rules it's legal, and the map will fail to maintain its invariants.

1#include &lt;string&gt;
2#include &lt;memory&gt;
3
4struct A
5{
6    // const std::string s; // Oddly, declaring s const compiles
7    std::string s;
8    constexpr A() = default;
9    constexpr A(A&amp;&amp; rh) = default;
10    constexpr A&amp; operator=(A&amp;&amp; rh) noexcept
11    {
12        std::destroy_at(this);
13        std::construct_at(this, std::move(rh));
14        return *this;
15    }
16};
17
18constexpr int foo()
19{
20    A i0{};    // call ctor
21    // Fails with clang. OK msvc, gcc
22    // construction of subobject of member '_M_local_buf' of union with no active member is not allowed in a constant expression { return ::new((void*)__location) _Tp(std::forward&lt;_Args&gt;(__args)...); }
23    i0 = A{};  // call assign rctor
24    return 42;
25}
26
27int main() {
28    constexpr int i = foo();
29    return i;
30}
31std::map&lt;int, T&gt; m{data_source()};
32/* new code, now legal */
33for( auto&amp; keyvalue : m ) {
34    int newkey = -keyvalue.first;
35    std::construct_at(&amp;keyvalue.first, newkey);
36    // or new (&amp;keyvalue.first) int(newkey);
37}
38/* existing valid code that breaks */
39std::cout &lt;&lt; m[some_key()];
40

Consider the new relaxed wording of the restriction

the original object is neither a complete object that is const-qualified nor a subobject of such an object

keyvalue.first is const-qualified, but it is not a complete object, and it is a subobject of a complete object (std::pair<const Key, Value>) that is not const-qualified. This code is now legal. It's not even against the spirit of the rule, the DR explicitly mentioned the intent to perform in-place replacement of container elements with const subobjects.

It's the implementation of std::map that breaks, along with all existing code that uses the map instance, an unfortunate action-at-a-distance resulting from addition of now-legal code.

Please note that the actual replacement of the key could take place in code that merely has the pointer &keyvalue and needn't know that std::pair instance is actually inside a std::map), so the stupidity of what's being done won't be so obvious.

Source https://stackoverflow.com/questions/71885720

QUESTION

Raku Ambiguous call to infix(Hyper: Dan::Series, Int)

Asked 2022-Mar-31 at 13:17

I am writing a model Series class (kinda like the one in pandas) - and it should be both Positional and Associative.

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86

So far pretty darn cool.

I can go dd $s.hyper and get this

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87

BUT (there had to be a but coming), I want to be able to do hyper math on my Series' elements, something like:

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87say $s &gt;&gt;+&gt;&gt; 2;
88

But that yields:

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87say $s &gt;&gt;+&gt;&gt; 2;
88Ambiguous call to 'infix(Hyper: Dan::Series, Int)'; these signatures all match:
89  (Hyper: Associative:D \left, \right, *%_)
90  (Hyper: Positional:D \left, \right, *%_)
91  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
92

How can I tell my class Series not to offer the Associative hyper candidate...?


Note: edited example to be a runnable MRE per @raiph's comment ... I have thus left in the minimum requirements for the 3 roles in play per docs.raku.org

ANSWER

Answered 2022-Mar-31 at 13:17
Take #1

First, an MRE with an emphasis on the M1:

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87say $s &gt;&gt;+&gt;&gt; 2;
88Ambiguous call to 'infix(Hyper: Dan::Series, Int)'; these signatures all match:
89  (Hyper: Associative:D \left, \right, *%_)
90  (Hyper: Positional:D \left, \right, *%_)
91  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
92class foo does Positional does Associative { method of {} }
93sub infix:&lt;baz&gt; (\l,\r) { say 'baz' }
94foo.new &gt;&gt;baz&gt;&gt; 42;
95

yields:

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87say $s &gt;&gt;+&gt;&gt; 2;
88Ambiguous call to 'infix(Hyper: Dan::Series, Int)'; these signatures all match:
89  (Hyper: Associative:D \left, \right, *%_)
90  (Hyper: Positional:D \left, \right, *%_)
91  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
92class foo does Positional does Associative { method of {} }
93sub infix:&lt;baz&gt; (\l,\r) { say 'baz' }
94foo.new &gt;&gt;baz&gt;&gt; 42;
95Ambiguous call to 'infix(Hyper: foo, Int)'; these signatures all match:
96  (Hyper: Associative:D \left, \right, *%_)
97  (Hyper: Positional:D \left, \right, *%_)
98  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
99

The error message shows it's A) a call to a method named infix with an invocant matching Hyper, and B) there are two methods that potentially match that call.

Given that there's no class Hyper in your MRE, these methods and the Hyper class must be either built-ins or internal details that are leaking out.

A search of the doc finds no such class. So Hyper is undocumented Given that the doc has fairly broad coverage these days, this suggests Hyper is an internal detail. But regardless, it looks like you can't solve your problem using official/documented features.

Hopefully this bad news is still better than none.2

Take #2

Where's the fun in letting little details like "not an official feature" stop us doing what we want to do?

There's a core.c module named Hyper.pm6 in the Rakudo source repo.

A few seconds browsing that, and clicks on its History and Blame, and I can instantly see it really is time for me to conclude this SO answer, with a recommendation for your next move.

To wit, I suggest you start another SO, using this answer as its heart (but reversing my presentation order, ie starting by mentioning Hyper, and that it's not doc'd), and namechecking Liz (per Hyper's History/Blame), with a link back to your Q here as its background. I'm pretty sure that will get you a good answer, or at least an authoritative one.

Footnotes

1 I also tried this:

1class Series does Positional does Iterable does Associative {
2    has Array $.data is required;
3    has Array $.index;
4
5    ### Construction ###
6
7    method TWEAK {
8        # sort out data-index dependencies
9        $!index = gather {
10            my $i = 0;
11            for |$!data -&gt; $d {
12                take ( $!index[$i++] =&gt; $d )
13            }
14        }.Array
15    }
16
17    ### Output ### 
18
19    method Str {
20        $!index
21    }   
22
23    ### Role Support ### 
24
25    # Positional role support
26    # viz. https://docs.raku.org/type/Positional
27
28    method of {
29        Mu  
30    }   
31    method elems {
32        $!data.elems
33    }   
34    method AT-POS( $p ) { 
35        $!data[$p]
36    }   
37    method EXISTS-POS( $p ) { 
38        0 &lt;= $p &lt; $!data.elems ?? True !! False
39    }   
40
41    # Iterable role support
42    # viz. https://docs.raku.org/type/Iterable
43
44    method iterator {
45        $!data.iterator
46    }   
47    method flat {
48        $!data.flat
49    }   
50    method lazy {
51        $!data.lazy
52    }   
53    method hyper {
54        $!data.hyper
55    }   
56
57    # Associative role support
58    # viz. https://docs.raku.org/type/Associative
59
60    method keyof {
61        Str(Any)
62    }   
63    method AT-KEY( $k ) { 
64        for |$!index -&gt; $p {
65            return $p.value if $p.key ~~ $k
66        }   
67    }   
68    method EXISTS-KEY( $k ) { 
69        for |$!index -&gt; $p {
70            return True if $p.key ~~ $k
71        }   
72    }   
73
74    #`[ solution attempt #1 does NOT get called
75    multi method infix(Hyper: Series, Int) is default {
76        die &quot;I was called&quot;
77    }
78    #]
79}
80
81my $s = Series.new(data =&gt; [rand xx 5], index =&gt; [&lt;a b c d e&gt;]);
82
83say ~$s;
84say $s[2];
85say $s&lt;b&gt;;
86HyperSeq.new(configuration =&gt; HyperConfiguration.new(batch =&gt; 64, degree =&gt; 1))
87say $s &gt;&gt;+&gt;&gt; 2;
88Ambiguous call to 'infix(Hyper: Dan::Series, Int)'; these signatures all match:
89  (Hyper: Associative:D \left, \right, *%_)
90  (Hyper: Positional:D \left, \right, *%_)
91  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
92class foo does Positional does Associative { method of {} }
93sub infix:&lt;baz&gt; (\l,\r) { say 'baz' }
94foo.new &gt;&gt;baz&gt;&gt; 42;
95Ambiguous call to 'infix(Hyper: foo, Int)'; these signatures all match:
96  (Hyper: Associative:D \left, \right, *%_)
97  (Hyper: Positional:D \left, \right, *%_)
98  in block &lt;unit&gt; at ./synopsis-dan.raku line 63
99class foo does Positional does Associative { method of {} }
100sub postfix:&lt;bar&gt;(\arg) { say 'bar' }
101foo.new&gt;&gt;bar;
102

but that worked (displayed bar).

2 If you didn't get to my Take #1 conclusion yourself, perhaps that was was because your MRE wasn't very M? If you did arrive at the same point (cf "solution attempt #1 does NOT get called" in your MRE) then please read and, for future SOs, take to heart, the wisdom of "Explain ... any difficulties that have prevented you from solving it yourself".

Source https://stackoverflow.com/questions/70643520

QUESTION

how to use release branch to increment version using setuptools_scm?

Asked 2022-Mar-16 at 08:51

I am looking at https://github.com/pypa/setuptools_scm

and I read this part https://github.com/pypa/setuptools_scm#version-number-construction

and i quote

Semantic versioning for projects with release branches. The same as guess-next-dev (incrementing the pre-release or micro segment) if on a release branch: a branch whose name (ignoring namespace) parses as a version that matches the most recent tag up to the minor segment. Otherwise if on a non-release branch, increments the minor segment and sets the micro segment to zero, then appends .devN.

How does this work?

Assuming my setup is at this commit https://github.com/simkimsia/test-setup-py/commit/5ebab14b16b63090ad0554ad8f9a77a28b047323

and the same repo, how do i increment the version by branching?

What i tried on 2022-03-15

I updated some files on main branch.

Then i did the following

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16

Then i push my changes including the tag

So this commit is https://github.com/simkimsia/test-setup-py/commit/75838db70747fd06cc190218562d0548baa16e9d

When I run python -m demopublicpythonproject the version that appears is correct

enter image description here

The version number that appears here is based on https://github.com/simkimsia/test-setup-py/blob/75838db70747fd06cc190218562d0548baa16e9d/demopublicpythonproject/framework/__init__.py#L14

Then i branch off

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17

Then i added a pyproject.toml and set to release-branch

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21
1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21python -m setuptools_scm
22

I get

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21python -m setuptools_scm
22/Users/kimsia/.venv/test-setup-py-py3812/bin/python: No module named setuptools_scm
23

In any case i run the following

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21python -m setuptools_scm
22/Users/kimsia/.venv/test-setup-py-py3812/bin/python: No module named setuptools_scm
23pip-compile
24
25pip-sync
26
27pip install -e .
28
29git commit -m 'Attempt to do branch semver'
30

then i have this commit as a result https://github.com/simkimsia/test-setup-py/commit/527885531afe37014dc66432a43a402ec0808caa

When I run python -m demopublicpythonproject I get this image

enter image description here

The version appears to follow based on the branch number but i might be wrong because the latest tag is v0.0.0

so i

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21python -m setuptools_scm
22/Users/kimsia/.venv/test-setup-py-py3812/bin/python: No module named setuptools_scm
23pip-compile
24
25pip-sync
26
27pip install -e .
28
29git commit -m 'Attempt to do branch semver'
30git checkout -b main
31git checkout -b v0.1.0
32pip-sync
33pip install -e .      
34python -m demopublicpythonproject
35

i get a different version number

0.0.1.dev1+g45f5696 but not 0.1.0

ANSWER

Answered 2022-Mar-13 at 15:39

If I'm reading the docs correctly, this likely means you are supposed to create branches like so (assuming your current version is 0.x):

1python -m pip install --upgrade &quot;pip ~= 21.3&quot;
2
3pip install pip-tools &quot;pip-tools ~= 6.5&quot;
4
5git init .
6
7git add .
8git commit -m '♻️ REFACTOR'
9git tag -a v0.0.0 -m '🔖 First tag v0.0.0'
10
11pip-compile
12
13pip-sync
14
15pip install -e .
16git checkout -b v0.0.1
17# pyproject.toml
18[build-system]
19requires = [&quot;setuptools&gt;=45&quot;, &quot;setuptools_scm[toml]&gt;=6.2&quot;]
20version_scheme = &quot;release-branch-semver&quot;
21python -m setuptools_scm
22/Users/kimsia/.venv/test-setup-py-py3812/bin/python: No module named setuptools_scm
23pip-compile
24
25pip-sync
26
27pip install -e .
28
29git commit -m 'Attempt to do branch semver'
30git checkout -b main
31git checkout -b v0.1.0
32pip-sync
33pip install -e .      
34python -m demopublicpythonproject
35main (main development branch)
361.0 (release branch for 1.0)
372.0 (development branch for 2.0)
38

My understanding is this is parsed like so:

The docs say

Semantic versioning for projects with release branches. The same as guess-next-dev (incrementing the pre-release or micro segment) if on a release branch: a branch whose name (ignoring namespace) parses as a version that matches the most recent tag up to the minor segment. Otherwise if on a non-release branch, increments the minor segment and sets the micro segment to zero, then appends .devN.

So my understanding of this is:

You want to make a new version. So you put it on a branch called 2.0. Since the program knows your last version was 2.0.0, your new one will be called 2.0.1.

Basically, it auto-increments the micro version on your version tag.

Source https://stackoverflow.com/questions/71090408

QUESTION

Is Shannon-Fano coding ambiguous?

Asked 2022-Mar-08 at 19:38
In a nutshell:

Is the Shannon-Fano coding as described in Fano's paper The Transmission of Information (1952) really ambiguous?

In Detail:

3 papers
Claude E. Shannon published his famous paper A Mathematical Theory of Communication in July 1948. In this paper he invented the term bit as we know it today and he also defined what we call Shannon entropy today. And he also proposed an entropy based data compression algorithm in this paper. But Shannon's algorithm was so weak, that under certain circumstances the "compressed" messages could be even longer than in fix length coding. A few month later (March 1949) Robert M. Fano published an improved version of Shannons algorithm in the paper The Transmission of Information. 3 years after Fano (in September 1952) his student David A. Huffman published an even better version in his paper A Method for the Construction of Minimum-Redundancy Codes. Hoffman Coding is more efficient than its two predecessors and it is still used today. But my question is about the algorithm published by Fano which usually is called Shannon-Fano-Coding.

The algorithm
This description is based on the description from Wikipedia. Sorry, I did not fully read Fano's paper. I only browsed through it. It is 37 pages long and I really tried hard to find a passage where he talks about the topic of my question, but I could not find it. So, here is how Shannon-Fano encoding works:

  1. Count how often each character appears in the message.
  2. Sort all characters by frequency, characters with highest frequency on top of the list
  3. Divide the list into two parts, such that the sums of frequencies in both parts are as equal as possible. Add the bit 0 to one part and the bit 1 to the other part.
  4. Repeat step 3 on each part that contains 2 or more characters until all parts consist of only 1 character.
  5. Concatenate all bits from all rounds. This is the Shannon-Fano-code of that character.

An example
Let's execute this on a really tiny example (I think it's the smallest message where the problem appears). Here is the message to encode:

1aaabcde
2

Steps 1 and 2 produce the first 2 columns of both tables shown below. But if Wikipedia's explanation of Fanos's algorithm is correct, then step 3 is ambiguous. If you apply this step on my example, you have two possibilities to split the list in 2 parts (see below). These possibilities produce different codes, which by itself would not be worth to be mentioned. But the point is: The two possibilities produce codes of different lengths.


possibility 1

If there are 2 ways to split the list such that both parts are as equal to each other as possible, then put that character, that stands at the splitting point (this is character b in my example) to the part containing the low frequent characters

1aaabcde
2+------+-------+-----+-----+-----+-----+-----+-----+------+
3|      |       |   round1  |   round2  |   round3  |      |
4| char | frequ | sum | bit | sum | bit | sum | bit | code |
5+------+-------+-----+-----+-----+-----+-----+-----+------+
6|   a  |   3   |  3  |  0  |                       | 0    |
7|      |       +-----+-----+-----+-----+-----+-----+------+
8|   b  |   1   |     |     |     |     |  1  |  0  | 100  |
9|      |       |     |     |  2  |  0  +-----+-----+------+
10|   c  |   1   |     |     |     |     |  1  |  1  | 101  |
11|      |       |  4  |  1  +-----+-----+-----+-----+------+
12|   d  |   1   |     |     |     |     |  1  |  0  | 110  |
13|      |       |     |     |  2  |  1  +-----+-----+------+
14|   e  |   1   |     |     |     |     |  1  |  1  | 111  |
15+------+-------+-----+-----+-----+-----+-----+-----+------+
16

The encoded message is

1aaabcde
2+------+-------+-----+-----+-----+-----+-----+-----+------+
3|      |       |   round1  |   round2  |   round3  |      |
4| char | frequ | sum | bit | sum | bit | sum | bit | code |
5+------+-------+-----+-----+-----+-----+-----+-----+------+
6|   a  |   3   |  3  |  0  |                       | 0    |
7|      |       +-----+-----+-----+-----+-----+-----+------+
8|   b  |   1   |     |     |     |     |  1  |  0  | 100  |
9|      |       |     |     |  2  |  0  +-----+-----+------+
10|   c  |   1   |     |     |     |     |  1  |  1  | 101  |
11|      |       |  4  |  1  +-----+-----+-----+-----+------+
12|   d  |   1   |     |     |     |     |  1  |  0  | 110  |
13|      |       |     |     |  2  |  1  +-----+-----+------+
14|   e  |   1   |     |     |     |     |  1  |  1  | 111  |
15+------+-------+-----+-----+-----+-----+-----+-----+------+
16000100101110111  length = 15 bit
17aaab  c  d  e
18

possibility 2

If there are 2 ways to split the list such that both parts are as equal to each other as possible, then put that character, that stands at the splitting point to the part containing the high frequent characters

1aaabcde
2+------+-------+-----+-----+-----+-----+-----+-----+------+
3|      |       |   round1  |   round2  |   round3  |      |
4| char | frequ | sum | bit | sum | bit | sum | bit | code |
5+------+-------+-----+-----+-----+-----+-----+-----+------+
6|   a  |   3   |  3  |  0  |                       | 0    |
7|      |       +-----+-----+-----+-----+-----+-----+------+
8|   b  |   1   |     |     |     |     |  1  |  0  | 100  |
9|      |       |     |     |  2  |  0  +-----+-----+------+
10|   c  |   1   |     |     |     |     |  1  |  1  | 101  |
11|      |       |  4  |  1  +-----+-----+-----+-----+------+
12|   d  |   1   |     |     |     |     |  1  |  0  | 110  |
13|      |       |     |     |  2  |  1  +-----+-----+------+
14|   e  |   1   |     |     |     |     |  1  |  1  | 111  |
15+------+-------+-----+-----+-----+-----+-----+-----+------+
16000100101110111  length = 15 bit
17aaab  c  d  e
18+------+-------+-----+-----+-----+-----+-----+-----+------+
19|      |       |   round1  |   round2  |   round3  |      |
20| char | frequ | sum | bit | sum | bit | sum | bit | code |
21+------+-------+-----+-----+-----+-----+-----+-----+------+
22|   a  |   3   |     |     |  3  |  0  |           | 00   |
23|      |       |  4  |  0  +-----+-----+           +------+
24|   b  |   1   |     |     |  1  |  1  |           | 01   |
25|      |       +-----+-----+-----+-----+-----+-----+------+
26|   c  |   1   |     |     |     |     |  1  |  0  | 100  |
27|      |       |     |     |  2  |  0  |-----+-----+------+
28|   d  |   1   |  3  |  1  |     |     |  1  |  1  | 101  |
29|      |       |     |     +-----+-----+-----+-----+------+
30|   e  |   1   |     |     |  1  |  1  |           | 11   |
31+------+-------+-----+-----+-----+-----+-----+-----+------+
32

The encoded message is

1aaabcde
2+------+-------+-----+-----+-----+-----+-----+-----+------+
3|      |       |   round1  |   round2  |   round3  |      |
4| char | frequ | sum | bit | sum | bit | sum | bit | code |
5+------+-------+-----+-----+-----+-----+-----+-----+------+
6|   a  |   3   |  3  |  0  |                       | 0    |
7|      |       +-----+-----+-----+-----+-----+-----+------+
8|   b  |   1   |     |     |     |     |  1  |  0  | 100  |
9|      |       |     |     |  2  |  0  +-----+-----+------+
10|   c  |   1   |     |     |     |     |  1  |  1  | 101  |
11|      |       |  4  |  1  +-----+-----+-----+-----+------+
12|   d  |   1   |     |     |     |     |  1  |  0  | 110  |
13|      |       |     |     |  2  |  1  +-----+-----+------+
14|   e  |   1   |     |     |     |     |  1  |  1  | 111  |
15+------+-------+-----+-----+-----+-----+-----+-----+------+
16000100101110111  length = 15 bit
17aaab  c  d  e
18+------+-------+-----+-----+-----+-----+-----+-----+------+
19|      |       |   round1  |   round2  |   round3  |      |
20| char | frequ | sum | bit | sum | bit | sum | bit | code |
21+------+-------+-----+-----+-----+-----+-----+-----+------+
22|   a  |   3   |     |     |  3  |  0  |           | 00   |
23|      |       |  4  |  0  +-----+-----+           +------+
24|   b  |   1   |     |     |  1  |  1  |           | 01   |
25|      |       +-----+-----+-----+-----+-----+-----+------+
26|   c  |   1   |     |     |     |     |  1  |  0  | 100  |
27|      |       |     |     |  2  |  0  |-----+-----+------+
28|   d  |   1   |  3  |  1  |     |     |  1  |  1  | 101  |
29|      |       |     |     +-----+-----+-----+-----+------+
30|   e  |   1   |     |     |  1  |  1  |           | 11   |
31+------+-------+-----+-----+-----+-----+-----+-----+------+
320000000110010111  length = 16 bit
33a a a b c  d  e
34

So, it is one bit longer.


So, here are my questions:
  • Is Wikipedia's description of Shannon-Fano Coding really correct and complete? If this is the case, than Shannon-Fano Coding is ambiguous.
  • Or did Fano in his paper add another step that is missing in Wikipedia's description? If this is the case: How did Fano solve the problem described here? Which of both versions is compatible with Fano's original description?

ANSWER

Answered 2022-Mar-08 at 19:00

To directly answer your question, without further elaboration about how to break ties, two different implementations of Shannon-Fano could produce different codes of different lengths for the same inputs.

As @MattTimmermans noted in the comments, Shannon-Fano does not always produce optimal prefix-free codings the way that, say, Huffman coding does. It might therefore be helpful to think of it less as an algorithm and more of a heuristic - something that likely will produce a good code but isn't guaranteed to give an optimal solution. Many heuristics suffer from similar issues, where minor tweaks in the input or how ties are broken could result in different results. A good example of this is the greedy coloring algorithm for finding vertex colorings of graphs. The linked Wikipedia article includes an example in which changing the order in which nodes are visited by the same basic algorithm yields wildly different results.

Even algorithms that produce optimal results, however, can sometimes produce different optimal results based on tiebreaks. Take Huffman coding, for example, which works by repeatedly finding the two lowest-weight trees assembled so far and merging them together. In the event that there are three or more trees at some intermediary step that are all tied for the same weight, different implementations of Huffman coding could produce different prefix-free codes based on which two they join together. The resulting trees would all be equally "good," though, in that they'd all produce outputs of the same length. (That's largely because, unlike Shannon-Fano, Huffman coding is guaranteed to produce an optimal encoding.)

That being said, it's easy to adjust Shannon-Fano so that it always produces a consistent result. For example, you could say "in the event of a tie, choose the partition that puts fewer items into the top group," at which point you would always consistently produce the same coding. It wouldn't necessarily be an optimal encoding, but, then again, since Shannon-Fano was never guaranteed to do so, this is probably not a major concern.

If, on the other hand, you're interested in the question of "when Shannon-Fano has to break a tie, how do I decide how to break the tie to produce the optimal solution?," then I'm not sure of a way to do this other than recursively trying both options and seeing which one is better, which in the worst case leads to exponentially-slow runtimes. But perhaps someone else here can find a way to do that>

Source https://stackoverflow.com/questions/71399572

QUESTION

std::vector move assignment vs construction: why is the state of 'other' not consistent?

Asked 2022-Feb-24 at 11:57

For move construction:

After the move, other is guaranteed to be empty(). 1

For move assignment, the oft-quoted:

other is in a valid but unspecified state afterwards. 2

Why is the state of other different in these two cases?

ANSWER

Answered 2022-Feb-24 at 08:24

There are 2 popular ways to implement move in containers like vector that internally hold a pointer to the data:

  • you can empty this, then copy the pointer (and size and capacity) from other to this and then set other members to nullptr/zero
  • you can swap the data members (the pointers, size and capacity).

The standard wants to leave leeway to implementations to do either. These guarantees are the strongest guarantees it can make while allowing either methods of implementation:

  • move constructor:

    • 1st method: leaves other in empty state
    • 2st method (swap): leaves other in empty state
  • move assignment:

    • 1st method: leaves other in empty state
    • 2st method (swap): leaves other as a copy of initial this

Source https://stackoverflow.com/questions/71247774

QUESTION

C++ - Why does aggregate initialization not work with template struct

Asked 2022-Jan-19 at 07:39

This code works, without having to specify a constructor:

1struct Foo
2{
3    int a;
4    int b;
5};
6
7//...
8
9    int a1, b1;
10
11    Foo foo = {a1, b1};
12

If I make Foo a template, it doesn't work.

1struct Foo
2{
3    int a;
4    int b;
5};
6
7//...
8
9    int a1, b1;
10
11    Foo foo = {a1, b1};
12template&lt;typename T1, typename T2&gt;
13struct Foo
14{
15    T1 a;
16    T2 b;
17};
18
19//...
20
21    int a1, b1;
22
23    Foo foo = {a1, b1};
24

It says deduction failed / 2 arguments were provided while 1 expected. If I add a constructor like Foo(T1, T2){} then it works. I thought, that sort of construction just works by default for structs. What am I getting wrong?

EDIT: I'm using Clang, which seems not to support it. Both MSVC and GCC compile it with c++20 compiler flag.

ANSWER

Answered 2022-Jan-19 at 07:34

Since C++20 aggregates have implicitly-generated deduction guide so class template argument deduction works for aggregates too.

1struct Foo
2{
3    int a;
4    int b;
5};
6
7//...
8
9    int a1, b1;
10
11    Foo foo = {a1, b1};
12template&lt;typename T1, typename T2&gt;
13struct Foo
14{
15    T1 a;
16    T2 b;
17};
18
19//...
20
21    int a1, b1;
22
23    Foo foo = {a1, b1};
24int a1, b1;
25Foo foo = {a1, b1}; // works since C++20; T1 and T2 are deduced as int
26

Before C++20, you need to add user-defined deduction guide, e.g.

1struct Foo
2{
3    int a;
4    int b;
5};
6
7//...
8
9    int a1, b1;
10
11    Foo foo = {a1, b1};
12template&lt;typename T1, typename T2&gt;
13struct Foo
14{
15    T1 a;
16    T2 b;
17};
18
19//...
20
21    int a1, b1;
22
23    Foo foo = {a1, b1};
24int a1, b1;
25Foo foo = {a1, b1}; // works since C++20; T1 and T2 are deduced as int
26template&lt;typename T1, typename T2&gt;
27struct Foo
28{
29    T1 a;
30    T2 b;
31};
32
33template&lt;class T1, class T2&gt; Foo(T1 a, T2 b) -&gt; Foo&lt;T1, T2&gt;;
34

Clang has not supported class template argument deduction for aggregates yet.

Source https://stackoverflow.com/questions/70766614

QUESTION

I have a dataset in which i have two columns with time in it but the dat

Asked 2021-Dec-22 at 17:00
1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44

this is how my data looks like. What I want to do here is to extract date from created date and closed date I have tried .extract method but I am new to this so, it didn't work. I want to calculate housrs from created date and closed which i can do like this:

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45

In the end I want the output Find average completion time in hours for top-10 most frequent complaints. Also calculate how many data points you have for each complaint types. Do this analysis only for closed complaints. The sample output I want is as follows:

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45                         mean                   count
46complaint Type           closing_time_hours     closing_time_hours
47Blocked Driveway         3.00                   4581
48DOF Literature Request   30.16                  5481
49General Construction     66.38                  798
50Heating                  54.88                  6704
51Illegal Parking          3.08                   3336
52Nonconst                 65                     100 
53Paint-Plaster            49                     3281 
54Plumbing                 65                     666   
55Strret Condition         81                     2610    
56Street Light Condition   90                     4207
57

these mean and count values are randomly generated The sample output can be produced by groupby function once the hours are extracted from the data. dictionary format

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45                         mean                   count
46complaint Type           closing_time_hours     closing_time_hours
47Blocked Driveway         3.00                   4581
48DOF Literature Request   30.16                  5481
49General Construction     66.38                  798
50Heating                  54.88                  6704
51Illegal Parking          3.08                   3336
52Nonconst                 65                     100 
53Paint-Plaster            49                     3281 
54Plumbing                 65                     666   
55Strret Condition         81                     2610    
56Street Light Condition   90                     4207
57{'Unnamed: 0': {2869: 2869,
58  23571: 23571,
59  41625: 41625,
60  44331: 44331,
61  46913: 46913,
62  47459: 47459,
63  48465: 48465,
64  51837: 51837,
65  51848: 51848,
66  54089: 54089,
67  54343: 54343,
68  55140: 55140,
69  57789: 57789,
70  63119: 63119,
71  66242: 66242,
72  66758: 66758,
73  66786: 66786,
74  66809: 66809,
75  67465: 67465,
76  72424: 72424,
77  75531: 75531,
78  77918: 77918,
79  78048: 78048,
80  78352: 78352,
81  78383: 78383,
82  79078: 79078,
83  84489: 84489,
84  84518: 84518,
85  84688: 84688,
86  84695: 84695,
87  88812: 88812,
88  89205: 89205,
89  89382: 89382,
90  89734: 89734,
91  93990: 93990,
92  99407: 99407,
93  99847: 99847,
94  100073: 100073,
95  101013: 101013,
96  104020: 104020,
97  106118: 106118,
98  106499: 106499},
99 'Created Date': {2869: '10/30/2013 09:14:47 AM',
100  23571: '10/25/2013 02:33:54 PM',
101  41625: '10/22/2013 09:33:56 PM',
102  44331: '10/22/2013 07:25:35 AM',
103  46913: '10/21/2013 05:03:26 PM',
104  47459: '10/21/2013 02:56:08 PM',
105  48465: '10/21/2013 10:44:10 AM',
106  51837: '10/20/2013 04:36:12 PM',
107  51848: '10/20/2013 04:26:03 PM',
108  54089: '10/19/2013 03:45:47 PM',
109  54343: '10/19/2013 01:27:43 PM',
110  55140: '10/19/2013 02:02:28 AM',
111  57789: '10/18/2013 11:55:44 AM',
112  63119: '10/17/2013 06:52:37 AM',
113  66242: '10/16/2013 01:56:24 PM',
114  66758: '10/16/2013 11:52:43 AM',
115  66786: '10/16/2013 11:42:23 AM',
116  66809: '10/16/2013 11:36:54 AM',
117  67465: '10/16/2013 09:14:35 AM',
118  72424: '10/15/2013 12:22:00 AM',
119  75531: '10/14/2013 10:59:20 AM',
120  77918: '10/13/2013 03:16:03 PM',
121  78048: '10/13/2013 01:06:02 PM',
122  78352: '10/13/2013 05:14:33 AM',
123  78383: '10/13/2013 03:50:02 AM',
124  79078: '10/12/2013 09:53:17 PM',
125  84489: '10/10/2013 07:16:16 PM',
126  84518: '10/10/2013 07:02:29 PM',
127  84688: '10/10/2013 05:39:19 PM',
128  84695: '10/10/2013 05:37:04 PM',
129  88812: '10/09/2013 09:17:15 PM',
130  89205: '10/09/2013 06:01:48 PM',
131  89382: '10/09/2013 04:53:01 PM',
132  89734: '10/09/2013 03:13:23 PM',
133  93990: '10/08/2013 06:14:15 PM',
134  99407: '10/07/2013 03:56:11 PM',
135  99847: '10/07/2013 02:33:21 PM',
136  100073: '10/07/2013 01:36:02 PM',
137  101013: '10/07/2013 10:05:18 AM',
138  104020: '10/06/2013 02:58:47 PM',
139  106118: '10/05/2013 03:24:47 PM',
140  106499: '10/05/2013 11:52:13 AM'},
141 'Closed Date': {2869: '10/30/2013 10:48:51 AM',
142  23571: '10/25/2013 03:36:36 PM',
143  41625: '10/24/2013 05:37:24 PM',
144  44331: '10/25/2013 10:40:35 AM',
145  46913: '10/23/2013 09:59:23 AM',
146  47459: '10/29/2013 06:17:10 PM',
147  48465: '10/21/2013 11:17:47 AM',
148  51837: '10/20/2013 06:35:49 PM',
149  51848: '10/20/2013 06:34:47 PM',
150  54089: '10/19/2013 04:10:11 PM',
151  54343: '10/28/2013 08:42:12 AM',
152  55140: '10/19/2013 02:19:55 AM',
153  57789: '10/23/2013 02:42:14 PM',
154  63119: '10/25/2013 06:49:59 PM',
155  66242: '10/22/2013 03:09:11 PM',
156  66758: '10/16/2013 04:35:34 PM',
157  66786: '10/18/2013 04:57:04 PM',
158  66809: '10/16/2013 12:34:23 PM',
159  67465: '10/16/2013 12:43:06 PM',
160  72424: '10/21/2013 12:16:15 PM',
161  75531: '10/14/2013 03:09:51 PM',
162  77918: '10/13/2013 03:25:45 PM',
163  78048: '10/21/2013 10:20:21 AM',
164  78352: '10/16/2013 01:42:42 PM',
165  78383: '10/13/2013 05:03:13 AM',
166  79078: '10/13/2013 02:52:07 AM',
167  84489: '10/10/2013 10:29:16 PM',
168  84518: '10/10/2013 10:29:16 PM',
169  84688: '10/10/2013 10:29:17 PM',
170  84695: '10/10/2013 10:30:19 PM',
171  88812: '10/23/2013 02:15:21 PM',
172  89205: '10/09/2013 09:04:26 PM',
173  89382: '10/18/2013 08:35:02 AM',
174  89734: '10/09/2013 05:10:45 PM',
175  93990: '10/09/2013 04:00:59 PM',
176  99407: '10/08/2013 07:04:14 AM',
177  99847: '10/09/2013 02:36:42 PM',
178  100073: '10/09/2013 09:56:55 AM',
179  101013: '10/09/2013 03:36:23 PM',
180  104020: '10/07/2013 12:11:16 PM',
181  106118: '10/05/2013 04:20:34 PM',
182  106499: '10/07/2013 08:00:28 AM'},
183 'Agency': {2869: 'NYPD',
184  23571: 'NYPD',
185  41625: 'TLC',
186  44331: 'TLC',
187  46913: 'DPR',
188  47459: 'TLC',
189  48465: 'NYPD',
190  51837: 'NYPD',
191  51848: 'NYPD',
192  54089: 'NYPD',
193  54343: 'DOT',
194  55140: 'NYPD',
195  57789: 'TLC',
196  63119: 'TLC',
197  66242: 'TLC',
198  66758: 'NYPD',
199  66786: 'TLC',
200  66809: 'NYPD',
201  67465: 'NYPD',
202  72424: 'TLC',
203  75531: 'NYPD',
204  77918: 'NYPD',
205  78048: 'TLC',
206  78352: 'TLC',
207  78383: 'NYPD',
208  79078: 'NYPD',
209  84489: 'NYPD',
210  84518: 'NYPD',
211  84688: 'NYPD',
212  84695: 'NYPD',
213  88812: 'TLC',
214  89205: 'NYPD',
215  89382: 'DOT',
216  89734: 'NYPD',
217  93990: 'TLC',
218  99407: 'DPR',
219  99847: 'TLC',
220  100073: 'TLC',
221  101013: 'TLC',
222  104020: 'TLC',
223  106118: 'NYPD',
224  106499: 'DOT'},
225 'Agency Name': {2869: 'New York City Police Department',
226  23571: 'New York City Police Department',
227  41625: 'Taxi and Limousine Commission',
228  44331: 'Taxi and Limousine Commission',
229  46913: 'Department of Parks and Recreation',
230  47459: 'Taxi and Limousine Commission',
231  48465: 'New York City Police Department',
232  51837: 'New York City Police Department',
233  51848: 'New York City Police Department',
234  54089: 'New York City Police Department',
235  54343: 'Department of Transportation',
236  55140: 'New York City Police Department',
237  57789: 'Taxi and Limousine Commission',
238  63119: 'Taxi and Limousine Commission',
239  66242: 'Taxi and Limousine Commission',
240  66758: 'New York City Police Department',
241  66786: 'Taxi and Limousine Commission',
242  66809: 'New York City Police Department',
243  67465: 'New York City Police Department',
244  72424: 'Taxi and Limousine Commission',
245  75531: 'New York City Police Department',
246  77918: 'New York City Police Department',
247  78048: 'Taxi and Limousine Commission',
248  78352: 'Taxi and Limousine Commission',
249  78383: 'New York City Police Department',
250  79078: 'New York City Police Department',
251  84489: 'New York City Police Department',
252  84518: 'New York City Police Department',
253  84688: 'New York City Police Department',
254  84695: 'New York City Police Department',
255  88812: 'Taxi and Limousine Commission',
256  89205: 'New York City Police Department',
257  89382: 'Department of Transportation',
258  89734: 'New York City Police Department',
259  93990: 'Taxi and Limousine Commission',
260  99407: 'Department of Parks and Recreation',
261  99847: 'Taxi and Limousine Commission',
262  100073: 'Taxi and Limousine Commission',
263  101013: 'Taxi and Limousine Commission',
264  104020: 'Taxi and Limousine Commission',
265  106118: 'New York City Police Department',
266  106499: 'Department of Transportation'},
267 'Complaint Type': {2869: 'Illegal Parking',
268  23571: 'Noise - Park',
269  41625: 'For Hire Vehicle Complaint',
270  44331: 'Taxi Complaint',
271  46913: 'Dead Tree',
272  47459: 'Taxi Complaint',
273  48465: 'Illegal Parking',
274  51837: 'Noise - Park',
275  51848: 'Noise - Park',
276  54089: 'Noise - Park',
277  54343: 'Street Condition',
278  55140: 'Noise - Vehicle',
279  57789: 'Taxi Complaint',
280  63119: 'Taxi Complaint',
281  66242: 'Taxi Complaint',
282  66758: 'Vending',
283  66786: 'Taxi Complaint',
284  66809: 'Traffic',
285  67465: 'Traffic',
286  72424: 'Taxi Complaint',
287  75531: 'Vending',
288  77918: 'Noise - Park',
289  78048: 'Taxi Complaint',
290  78352: 'For Hire Vehicle Complaint',
291  78383: 'Noise - Vehicle',
292  79078: 'Noise - Park',
293  84489: 'Noise - Park',
294  84518: 'Noise - Park',
295  84688: 'Noise - Park',
296  84695: 'Noise - Park',
297  88812: 'Taxi Complaint',
298  89205: 'Vending',
299  89382: 'Public Toilet',
300  89734: 'Noise - Park',
301  93990: 'Taxi Complaint',
302  99407: 'Overgrown Tree/Branches',
303  99847: 'Taxi Complaint',
304  100073: 'Taxi Complaint',
305  101013: 'Taxi Complaint',
306  104020: 'For Hire Vehicle Complaint',
307  106118: 'Noise - Park',
308  106499: 'Public Toilet'},
309 'Descriptor': {2869: 'Double Parked Blocking Traffic',
310  23571: 'Loud Music/Party',
311  41625: 'Car Service Company Complaint',
312  44331: 'Driver Complaint',
313  46913: 'Dead/Dying Tree',
314  47459: 'Driver Complaint',
315  48465: 'Posted Parking Sign Violation',
316  51837: 'Loud Music/Party',
317  51848: 'Loud Music/Party',
318  54089: 'Loud Music/Party',
319  54343: 'Rough, Pitted or Cracked Roads',
320  55140: 'Car/Truck Music',
321  57789: 'Driver Complaint',
322  63119: 'Driver Complaint',
323  66242: 'Driver Complaint',
324  66758: 'Unlicensed',
325  66786: 'Insurance Information Requested',
326  66809: 'Congestion/Gridlock',
327  67465: 'Drag Racing',
328  72424: 'Driver Complaint',
329  75531: 'In Prohibited Area',
330  77918: 'Loud Music/Party',
331  78048: 'Driver Complaint',
332  78352: 'Car Service Company Complaint',
333  78383: 'Car/Truck Music',
334  79078: 'Loud Music/Party',
335  84489: 'Loud Music/Party',
336  84518: 'Loud Music/Party',
337  84688: 'Loud Music/Party',
338  84695: 'Loud Music/Party',
339  88812: 'Driver Complaint',
340  89205: 'Unlicensed',
341  89382: 'Damaged Door',
342  89734: 'Loud Music/Party',
343  93990: 'Driver Complaint',
344  99407: 'Traffic Sign or Signal Blocked',
345  99847: 'Driver Complaint',
346  100073: 'Driver Complaint',
347  101013: 'Driver Complaint',
348  104020: 'Car Service Company Complaint',
349  106118: 'Loud Music/Party',
350  106499: 'Dirty/Graffiti'},
351 'Location Type': {2869: 'Street/Sidewalk',
352  23571: 'Park/Playground',
353  41625: 'Street',
354  44331: 'Street',
355  46913: 'Street',
356  47459: 'Street',
357  48465: 'Street/Sidewalk',
358  51837: 'Park/Playground',
359  51848: 'Park/Playground',
360  54089: 'Park/Playground',
361  54343: 'Street',
362  55140: 'Street/Sidewalk',
363  57789: 'Street',
364  63119: 'Street',
365  66242: 'Street',
366  66758: 'Park/Playground',
367  66786: 'Street',
368  66809: 'Street/Sidewalk',
369  67465: 'Street/Sidewalk',
370  72424: 'Street',
371  75531: 'Park/Playground',
372  77918: 'Park/Playground',
373  78048: 'Street',
374  78352: 'Street',
375  78383: 'Street/Sidewalk',
376  79078: 'Park/Playground',
377  84489: 'Park/Playground',
378  84518: 'Park/Playground',
379  84688: 'Park/Playground',
380  84695: 'Park/Playground',
381  88812: 'Street',
382  89205: 'Park/Playground',
383  89382: 'Sidewalk',
384  89734: 'Park/Playground',
385  93990: 'Street',
386  99407: 'Street',
387  99847: 'Street',
388  100073: 'Street',
389  101013: 'Street',
390  104020: 'Street',
391  106118: 'Park/Playground',
392  106499: 'Sidewalk'},
393 'Incident Zip': {2869: '11217.0',
394  23571: '10000',
395  41625: '11430',
396  44331: '11430',
397  46913: '11215',
398  47459: '10031',
399  48465: '11434',
400  51837: '10031.0',
401  51848: '10031.0',
402  54089: '10000.0',
403  54343: '10003.0',
404  55140: '11368.0',
405  57789: '11369.0',
406  63119: '11430.0',
407  66242: '11369',
408  66758: '10036',
409  66786: '10003',
410  66809: '11430',
411  67465: '11367',
412  72424: '11217',
413  75531: '10000',
414  77918: '10000',
415  78048: '11369',
416  78352: '11217',
417  78383: '11368',
418  79078: '10011',
419  84489: '11215',
420  84518: '11215',
421  84688: '11215',
422  84695: '11215',
423  88812: '11430',
424  89205: '10000',
425  89382: '11238',
426  89734: '10036',
427  93990: '10003',
428  99407: '11430.0',
429  99847: '10036.0',
430  100073: '10024.0',
431  101013: '10017.0',
432  104020: '11430.0',
433  106118: '10000.0',
434  106499: '11369.0'},
435 'Address Type': {2869: 'PLACENAME',
436  23571: 'PLACENAME',
437  41625: 'PLACENAME',
438  44331: 'PLACENAME',
439  46913: 'PLACENAME',
440  47459: 'PLACENAME',
441  48465: 'PLACENAME',
442  51837: 'PLACENAME',
443  51848: 'PLACENAME',
444  54089: 'PLACENAME',
445  54343: 'PLACENAME',
446  55140: 'PLACENAME',
447  57789: 'PLACENAME',
448  63119: 'PLACENAME',
449  66242: 'PLACENAME',
450  66758: 'PLACENAME',
451  66786: 'PLACENAME',
452  66809: 'PLACENAME',
453  67465: 'PLACENAME',
454  72424: 'PLACENAME',
455  75531: 'PLACENAME',
456  77918: 'PLACENAME',
457  78048: 'PLACENAME',
458  78352: 'PLACENAME',
459  78383: 'PLACENAME',
460  79078: 'PLACENAME',
461  84489: 'PLACENAME',
462  84518: 'PLACENAME',
463  84688: 'PLACENAME',
464  84695: 'PLACENAME',
465  88812: 'PLACENAME',
466  89205: 'PLACENAME',
467  89382: 'PLACENAME',
468  89734: 'PLACENAME',
469  93990: 'PLACENAME',
470  99407: 'PLACENAME',
471  99847: 'PLACENAME',
472  100073: 'PLACENAME',
473  101013: 'PLACENAME',
474  104020: 'PLACENAME',
475  106118: 'PLACENAME',
476  106499: 'PLACENAME'},
477 'City': {2869: 'BROOKLYN',
478  23571: 'NEW YORK',
479  41625: 'JAMAICA',
480  44331: 'JAMAICA',
481  46913: 'BROOKLYN',
482  47459: 'NEW YORK',
483  48465: 'JAMAICA',
484  51837: 'NEW YORK',
485  51848: 'NEW YORK',
486  54089: 'NEW YORK',
487  54343: 'NEW YORK',
488  55140: 'CORONA',
489  57789: 'EAST ELMHURST',
490  63119: 'JAMAICA',
491  66242: 'EAST ELMHURST',
492  66758: 'NEW YORK',
493  66786: 'NEW YORK',
494  66809: 'JAMAICA',
495  67465: 'FLUSHING',
496  72424: 'BROOKLYN',
497  75531: 'NEW YORK',
498  77918: 'NEW YORK',
499  78048: 'EAST ELMHURST',
500  78352: 'BROOKLYN',
501  78383: 'CORONA',
502  79078: 'NEW YORK',
503  84489: 'BROOKLYN',
504  84518: 'BROOKLYN',
505  84688: 'BROOKLYN',
506  84695: 'BROOKLYN',
507  88812: 'JAMAICA',
508  89205: 'NEW YORK',
509  89382: 'BROOKLYN',
510  89734: 'NEW YORK',
511  93990: 'NEW YORK',
512  99407: 'JAMAICA',
513  99847: 'NEW YORK',
514  100073: 'NEW YORK',
515  101013: 'NEW YORK',
516  104020: 'JAMAICA',
517  106118: 'NEW YORK',
518  106499: 'EAST ELMHURST'},
519 'Landmark': {2869: 'BARCLAYS CENTER',
520  23571: 'CENTRAL PARK',
521  41625: 'J F K AIRPORT',
522  44331: 'J F K AIRPORT',
523  46913: 'BARTEL PRITCHARD SQUARE',
524  47459: 'CITY COLLEGE',
525  48465: 'PS 37',
526  51837: 'JACKIE ROBINSON PARK',
527  51848: 'JACKIE ROBINSON PARK',
528  54089: 'CENTRAL PARK',
529  54343: 'UNION SQUARE PARK',
530  55140: 'WORLDS FAIR MARINA',
531  57789: 'LA GUARDIA AIRPORT',
532  63119: 'J F K AIRPORT',
533  66242: 'LA GUARDIA AIRPORT',
534  66758: 'BRYANT PARK',
535  66786: 'BETH ISRAEL MED CENTER',
536  66809: 'J F K AIRPORT',
537  67465: 'QUEENS COLLEGE',
538  72424: 'BARCLAYS CENTER',
539  75531: 'CENTRAL PARK',
540  77918: 'CENTRAL PARK',
541  78048: 'LA GUARDIA AIRPORT',
542  78352: 'BARCLAYS CENTER',
543  78383: 'WORLDS FAIR MARINA',
544  79078: 'WASHINGTON SQUARE PARK',
545  84489: 'PROSPECT PARK',
546  84518: 'PROSPECT PARK',
547  84688: 'PROSPECT PARK',
548  84695: 'PROSPECT PARK',
549  88812: 'J F K AIRPORT',
550  89205: 'CENTRAL PARK',
551  89382: 'GRAND ARMY PLAZA',
552  89734: 'BRYANT PARK',
553  93990: 'BETH ISRAEL MED CENTER',
554  99407: 'J F K AIRPORT',
555  99847: 'PORT AUTH 42 STREET',
556  100073: 'MUSEUM NATURAL HIST',
557  101013: 'GRAND CENTRAL TERM',
558  104020: 'JFK',
559  106118: 'CENTRAL PARK',
560  106499: 'LA GUARDIA AIRPORT'},
561 'Status': {2869: 'Closed',
562  23571: 'Closed',
563  41625: 'Closed',
564  44331: 'Closed',
565  46913: 'Closed',
566  47459: 'Closed',
567  48465: 'Closed',
568  51837: 'Closed',
569  51848: 'Closed',
570  54089: 'Closed',
571  54343: 'Closed',
572  55140: 'Closed',
573  57789: 'Closed',
574  63119: 'Closed',
575  66242: 'Closed',
576  66758: 'Closed',
577  66786: 'Closed',
578  66809: 'Closed',
579  67465: 'Closed',
580  72424: 'Closed',
581  75531: 'Closed',
582  77918: 'Closed',
583  78048: 'Closed',
584  78352: 'Closed',
585  78383: 'Closed',
586  79078: 'Closed',
587  84489: 'Closed',
588  84518: 'Closed',
589  84688: 'Closed',
590  84695: 'Closed',
591  88812: 'Closed',
592  89205: 'Closed',
593  89382: 'Closed',
594  89734: 'Closed',
595  93990: 'Closed',
596  99407: 'Closed',
597  99847: 'Closed',
598  100073: 'Closed',
599  101013: 'Closed',
600  104020: 'Closed',
601  106118: 'Closed',
602  106499: 'Closed'},
603 'Borough': {2869: 'BROOKLYN',
604  23571: 'MANHATTAN',
605  41625: 'QUEENS',
606  44331: 'QUEENS',
607  46913: 'BROOKLYN',
608  47459: 'MANHATTAN',
609  48465: 'QUEENS',
610  51837: 'MANHATTAN',
611  51848: 'MANHATTAN',
612  54089: 'MANHATTAN',
613  54343: 'MANHATTAN',
614  55140: 'QUEENS',
615  57789: 'QUEENS',
616  63119: 'QUEENS',
617  66242: 'QUEENS',
618  66758: 'MANHATTAN',
619  66786: 'MANHATTAN',
620  66809: 'QUEENS',
621  67465: 'QUEENS',
622  72424: 'BROOKLYN',
623  75531: 'MANHATTAN',
624  77918: 'MANHATTAN',
625  78048: 'QUEENS',
626  78352: 'BROOKLYN',
627  78383: 'QUEENS',
628  79078: 'MANHATTAN',
629  84489: 'BROOKLYN',
630  84518: 'BROOKLYN',
631  84688: 'BROOKLYN',
632  84695: 'BROOKLYN',
633  88812: 'QUEENS',
634  89205: 'MANHATTAN',
635  89382: 'BROOKLYN',
636  89734: 'MANHATTAN',
637  93990: 'MANHATTAN',
638  99407: 'QUEENS',
639  99847: 'MANHATTAN',
640  100073: 'MANHATTAN',
641  101013: 'MANHATTAN',
642  104020: 'QUEENS',
643  106118: 'MANHATTAN',
644  106499: 'QUEENS'}}
645

ANSWER

Answered 2021-Dec-22 at 17:00

You can first start by converting your date columns to datetime type using pd.to_datetime():

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45                         mean                   count
46complaint Type           closing_time_hours     closing_time_hours
47Blocked Driveway         3.00                   4581
48DOF Literature Request   30.16                  5481
49General Construction     66.38                  798
50Heating                  54.88                  6704
51Illegal Parking          3.08                   3336
52Nonconst                 65                     100 
53Paint-Plaster            49                     3281 
54Plumbing                 65                     666   
55Strret Condition         81                     2610    
56Street Light Condition   90                     4207
57{'Unnamed: 0': {2869: 2869,
58  23571: 23571,
59  41625: 41625,
60  44331: 44331,
61  46913: 46913,
62  47459: 47459,
63  48465: 48465,
64  51837: 51837,
65  51848: 51848,
66  54089: 54089,
67  54343: 54343,
68  55140: 55140,
69  57789: 57789,
70  63119: 63119,
71  66242: 66242,
72  66758: 66758,
73  66786: 66786,
74  66809: 66809,
75  67465: 67465,
76  72424: 72424,
77  75531: 75531,
78  77918: 77918,
79  78048: 78048,
80  78352: 78352,
81  78383: 78383,
82  79078: 79078,
83  84489: 84489,
84  84518: 84518,
85  84688: 84688,
86  84695: 84695,
87  88812: 88812,
88  89205: 89205,
89  89382: 89382,
90  89734: 89734,
91  93990: 93990,
92  99407: 99407,
93  99847: 99847,
94  100073: 100073,
95  101013: 101013,
96  104020: 104020,
97  106118: 106118,
98  106499: 106499},
99 'Created Date': {2869: '10/30/2013 09:14:47 AM',
100  23571: '10/25/2013 02:33:54 PM',
101  41625: '10/22/2013 09:33:56 PM',
102  44331: '10/22/2013 07:25:35 AM',
103  46913: '10/21/2013 05:03:26 PM',
104  47459: '10/21/2013 02:56:08 PM',
105  48465: '10/21/2013 10:44:10 AM',
106  51837: '10/20/2013 04:36:12 PM',
107  51848: '10/20/2013 04:26:03 PM',
108  54089: '10/19/2013 03:45:47 PM',
109  54343: '10/19/2013 01:27:43 PM',
110  55140: '10/19/2013 02:02:28 AM',
111  57789: '10/18/2013 11:55:44 AM',
112  63119: '10/17/2013 06:52:37 AM',
113  66242: '10/16/2013 01:56:24 PM',
114  66758: '10/16/2013 11:52:43 AM',
115  66786: '10/16/2013 11:42:23 AM',
116  66809: '10/16/2013 11:36:54 AM',
117  67465: '10/16/2013 09:14:35 AM',
118  72424: '10/15/2013 12:22:00 AM',
119  75531: '10/14/2013 10:59:20 AM',
120  77918: '10/13/2013 03:16:03 PM',
121  78048: '10/13/2013 01:06:02 PM',
122  78352: '10/13/2013 05:14:33 AM',
123  78383: '10/13/2013 03:50:02 AM',
124  79078: '10/12/2013 09:53:17 PM',
125  84489: '10/10/2013 07:16:16 PM',
126  84518: '10/10/2013 07:02:29 PM',
127  84688: '10/10/2013 05:39:19 PM',
128  84695: '10/10/2013 05:37:04 PM',
129  88812: '10/09/2013 09:17:15 PM',
130  89205: '10/09/2013 06:01:48 PM',
131  89382: '10/09/2013 04:53:01 PM',
132  89734: '10/09/2013 03:13:23 PM',
133  93990: '10/08/2013 06:14:15 PM',
134  99407: '10/07/2013 03:56:11 PM',
135  99847: '10/07/2013 02:33:21 PM',
136  100073: '10/07/2013 01:36:02 PM',
137  101013: '10/07/2013 10:05:18 AM',
138  104020: '10/06/2013 02:58:47 PM',
139  106118: '10/05/2013 03:24:47 PM',
140  106499: '10/05/2013 11:52:13 AM'},
141 'Closed Date': {2869: '10/30/2013 10:48:51 AM',
142  23571: '10/25/2013 03:36:36 PM',
143  41625: '10/24/2013 05:37:24 PM',
144  44331: '10/25/2013 10:40:35 AM',
145  46913: '10/23/2013 09:59:23 AM',
146  47459: '10/29/2013 06:17:10 PM',
147  48465: '10/21/2013 11:17:47 AM',
148  51837: '10/20/2013 06:35:49 PM',
149  51848: '10/20/2013 06:34:47 PM',
150  54089: '10/19/2013 04:10:11 PM',
151  54343: '10/28/2013 08:42:12 AM',
152  55140: '10/19/2013 02:19:55 AM',
153  57789: '10/23/2013 02:42:14 PM',
154  63119: '10/25/2013 06:49:59 PM',
155  66242: '10/22/2013 03:09:11 PM',
156  66758: '10/16/2013 04:35:34 PM',
157  66786: '10/18/2013 04:57:04 PM',
158  66809: '10/16/2013 12:34:23 PM',
159  67465: '10/16/2013 12:43:06 PM',
160  72424: '10/21/2013 12:16:15 PM',
161  75531: '10/14/2013 03:09:51 PM',
162  77918: '10/13/2013 03:25:45 PM',
163  78048: '10/21/2013 10:20:21 AM',
164  78352: '10/16/2013 01:42:42 PM',
165  78383: '10/13/2013 05:03:13 AM',
166  79078: '10/13/2013 02:52:07 AM',
167  84489: '10/10/2013 10:29:16 PM',
168  84518: '10/10/2013 10:29:16 PM',
169  84688: '10/10/2013 10:29:17 PM',
170  84695: '10/10/2013 10:30:19 PM',
171  88812: '10/23/2013 02:15:21 PM',
172  89205: '10/09/2013 09:04:26 PM',
173  89382: '10/18/2013 08:35:02 AM',
174  89734: '10/09/2013 05:10:45 PM',
175  93990: '10/09/2013 04:00:59 PM',
176  99407: '10/08/2013 07:04:14 AM',
177  99847: '10/09/2013 02:36:42 PM',
178  100073: '10/09/2013 09:56:55 AM',
179  101013: '10/09/2013 03:36:23 PM',
180  104020: '10/07/2013 12:11:16 PM',
181  106118: '10/05/2013 04:20:34 PM',
182  106499: '10/07/2013 08:00:28 AM'},
183 'Agency': {2869: 'NYPD',
184  23571: 'NYPD',
185  41625: 'TLC',
186  44331: 'TLC',
187  46913: 'DPR',
188  47459: 'TLC',
189  48465: 'NYPD',
190  51837: 'NYPD',
191  51848: 'NYPD',
192  54089: 'NYPD',
193  54343: 'DOT',
194  55140: 'NYPD',
195  57789: 'TLC',
196  63119: 'TLC',
197  66242: 'TLC',
198  66758: 'NYPD',
199  66786: 'TLC',
200  66809: 'NYPD',
201  67465: 'NYPD',
202  72424: 'TLC',
203  75531: 'NYPD',
204  77918: 'NYPD',
205  78048: 'TLC',
206  78352: 'TLC',
207  78383: 'NYPD',
208  79078: 'NYPD',
209  84489: 'NYPD',
210  84518: 'NYPD',
211  84688: 'NYPD',
212  84695: 'NYPD',
213  88812: 'TLC',
214  89205: 'NYPD',
215  89382: 'DOT',
216  89734: 'NYPD',
217  93990: 'TLC',
218  99407: 'DPR',
219  99847: 'TLC',
220  100073: 'TLC',
221  101013: 'TLC',
222  104020: 'TLC',
223  106118: 'NYPD',
224  106499: 'DOT'},
225 'Agency Name': {2869: 'New York City Police Department',
226  23571: 'New York City Police Department',
227  41625: 'Taxi and Limousine Commission',
228  44331: 'Taxi and Limousine Commission',
229  46913: 'Department of Parks and Recreation',
230  47459: 'Taxi and Limousine Commission',
231  48465: 'New York City Police Department',
232  51837: 'New York City Police Department',
233  51848: 'New York City Police Department',
234  54089: 'New York City Police Department',
235  54343: 'Department of Transportation',
236  55140: 'New York City Police Department',
237  57789: 'Taxi and Limousine Commission',
238  63119: 'Taxi and Limousine Commission',
239  66242: 'Taxi and Limousine Commission',
240  66758: 'New York City Police Department',
241  66786: 'Taxi and Limousine Commission',
242  66809: 'New York City Police Department',
243  67465: 'New York City Police Department',
244  72424: 'Taxi and Limousine Commission',
245  75531: 'New York City Police Department',
246  77918: 'New York City Police Department',
247  78048: 'Taxi and Limousine Commission',
248  78352: 'Taxi and Limousine Commission',
249  78383: 'New York City Police Department',
250  79078: 'New York City Police Department',
251  84489: 'New York City Police Department',
252  84518: 'New York City Police Department',
253  84688: 'New York City Police Department',
254  84695: 'New York City Police Department',
255  88812: 'Taxi and Limousine Commission',
256  89205: 'New York City Police Department',
257  89382: 'Department of Transportation',
258  89734: 'New York City Police Department',
259  93990: 'Taxi and Limousine Commission',
260  99407: 'Department of Parks and Recreation',
261  99847: 'Taxi and Limousine Commission',
262  100073: 'Taxi and Limousine Commission',
263  101013: 'Taxi and Limousine Commission',
264  104020: 'Taxi and Limousine Commission',
265  106118: 'New York City Police Department',
266  106499: 'Department of Transportation'},
267 'Complaint Type': {2869: 'Illegal Parking',
268  23571: 'Noise - Park',
269  41625: 'For Hire Vehicle Complaint',
270  44331: 'Taxi Complaint',
271  46913: 'Dead Tree',
272  47459: 'Taxi Complaint',
273  48465: 'Illegal Parking',
274  51837: 'Noise - Park',
275  51848: 'Noise - Park',
276  54089: 'Noise - Park',
277  54343: 'Street Condition',
278  55140: 'Noise - Vehicle',
279  57789: 'Taxi Complaint',
280  63119: 'Taxi Complaint',
281  66242: 'Taxi Complaint',
282  66758: 'Vending',
283  66786: 'Taxi Complaint',
284  66809: 'Traffic',
285  67465: 'Traffic',
286  72424: 'Taxi Complaint',
287  75531: 'Vending',
288  77918: 'Noise - Park',
289  78048: 'Taxi Complaint',
290  78352: 'For Hire Vehicle Complaint',
291  78383: 'Noise - Vehicle',
292  79078: 'Noise - Park',
293  84489: 'Noise - Park',
294  84518: 'Noise - Park',
295  84688: 'Noise - Park',
296  84695: 'Noise - Park',
297  88812: 'Taxi Complaint',
298  89205: 'Vending',
299  89382: 'Public Toilet',
300  89734: 'Noise - Park',
301  93990: 'Taxi Complaint',
302  99407: 'Overgrown Tree/Branches',
303  99847: 'Taxi Complaint',
304  100073: 'Taxi Complaint',
305  101013: 'Taxi Complaint',
306  104020: 'For Hire Vehicle Complaint',
307  106118: 'Noise - Park',
308  106499: 'Public Toilet'},
309 'Descriptor': {2869: 'Double Parked Blocking Traffic',
310  23571: 'Loud Music/Party',
311  41625: 'Car Service Company Complaint',
312  44331: 'Driver Complaint',
313  46913: 'Dead/Dying Tree',
314  47459: 'Driver Complaint',
315  48465: 'Posted Parking Sign Violation',
316  51837: 'Loud Music/Party',
317  51848: 'Loud Music/Party',
318  54089: 'Loud Music/Party',
319  54343: 'Rough, Pitted or Cracked Roads',
320  55140: 'Car/Truck Music',
321  57789: 'Driver Complaint',
322  63119: 'Driver Complaint',
323  66242: 'Driver Complaint',
324  66758: 'Unlicensed',
325  66786: 'Insurance Information Requested',
326  66809: 'Congestion/Gridlock',
327  67465: 'Drag Racing',
328  72424: 'Driver Complaint',
329  75531: 'In Prohibited Area',
330  77918: 'Loud Music/Party',
331  78048: 'Driver Complaint',
332  78352: 'Car Service Company Complaint',
333  78383: 'Car/Truck Music',
334  79078: 'Loud Music/Party',
335  84489: 'Loud Music/Party',
336  84518: 'Loud Music/Party',
337  84688: 'Loud Music/Party',
338  84695: 'Loud Music/Party',
339  88812: 'Driver Complaint',
340  89205: 'Unlicensed',
341  89382: 'Damaged Door',
342  89734: 'Loud Music/Party',
343  93990: 'Driver Complaint',
344  99407: 'Traffic Sign or Signal Blocked',
345  99847: 'Driver Complaint',
346  100073: 'Driver Complaint',
347  101013: 'Driver Complaint',
348  104020: 'Car Service Company Complaint',
349  106118: 'Loud Music/Party',
350  106499: 'Dirty/Graffiti'},
351 'Location Type': {2869: 'Street/Sidewalk',
352  23571: 'Park/Playground',
353  41625: 'Street',
354  44331: 'Street',
355  46913: 'Street',
356  47459: 'Street',
357  48465: 'Street/Sidewalk',
358  51837: 'Park/Playground',
359  51848: 'Park/Playground',
360  54089: 'Park/Playground',
361  54343: 'Street',
362  55140: 'Street/Sidewalk',
363  57789: 'Street',
364  63119: 'Street',
365  66242: 'Street',
366  66758: 'Park/Playground',
367  66786: 'Street',
368  66809: 'Street/Sidewalk',
369  67465: 'Street/Sidewalk',
370  72424: 'Street',
371  75531: 'Park/Playground',
372  77918: 'Park/Playground',
373  78048: 'Street',
374  78352: 'Street',
375  78383: 'Street/Sidewalk',
376  79078: 'Park/Playground',
377  84489: 'Park/Playground',
378  84518: 'Park/Playground',
379  84688: 'Park/Playground',
380  84695: 'Park/Playground',
381  88812: 'Street',
382  89205: 'Park/Playground',
383  89382: 'Sidewalk',
384  89734: 'Park/Playground',
385  93990: 'Street',
386  99407: 'Street',
387  99847: 'Street',
388  100073: 'Street',
389  101013: 'Street',
390  104020: 'Street',
391  106118: 'Park/Playground',
392  106499: 'Sidewalk'},
393 'Incident Zip': {2869: '11217.0',
394  23571: '10000',
395  41625: '11430',
396  44331: '11430',
397  46913: '11215',
398  47459: '10031',
399  48465: '11434',
400  51837: '10031.0',
401  51848: '10031.0',
402  54089: '10000.0',
403  54343: '10003.0',
404  55140: '11368.0',
405  57789: '11369.0',
406  63119: '11430.0',
407  66242: '11369',
408  66758: '10036',
409  66786: '10003',
410  66809: '11430',
411  67465: '11367',
412  72424: '11217',
413  75531: '10000',
414  77918: '10000',
415  78048: '11369',
416  78352: '11217',
417  78383: '11368',
418  79078: '10011',
419  84489: '11215',
420  84518: '11215',
421  84688: '11215',
422  84695: '11215',
423  88812: '11430',
424  89205: '10000',
425  89382: '11238',
426  89734: '10036',
427  93990: '10003',
428  99407: '11430.0',
429  99847: '10036.0',
430  100073: '10024.0',
431  101013: '10017.0',
432  104020: '11430.0',
433  106118: '10000.0',
434  106499: '11369.0'},
435 'Address Type': {2869: 'PLACENAME',
436  23571: 'PLACENAME',
437  41625: 'PLACENAME',
438  44331: 'PLACENAME',
439  46913: 'PLACENAME',
440  47459: 'PLACENAME',
441  48465: 'PLACENAME',
442  51837: 'PLACENAME',
443  51848: 'PLACENAME',
444  54089: 'PLACENAME',
445  54343: 'PLACENAME',
446  55140: 'PLACENAME',
447  57789: 'PLACENAME',
448  63119: 'PLACENAME',
449  66242: 'PLACENAME',
450  66758: 'PLACENAME',
451  66786: 'PLACENAME',
452  66809: 'PLACENAME',
453  67465: 'PLACENAME',
454  72424: 'PLACENAME',
455  75531: 'PLACENAME',
456  77918: 'PLACENAME',
457  78048: 'PLACENAME',
458  78352: 'PLACENAME',
459  78383: 'PLACENAME',
460  79078: 'PLACENAME',
461  84489: 'PLACENAME',
462  84518: 'PLACENAME',
463  84688: 'PLACENAME',
464  84695: 'PLACENAME',
465  88812: 'PLACENAME',
466  89205: 'PLACENAME',
467  89382: 'PLACENAME',
468  89734: 'PLACENAME',
469  93990: 'PLACENAME',
470  99407: 'PLACENAME',
471  99847: 'PLACENAME',
472  100073: 'PLACENAME',
473  101013: 'PLACENAME',
474  104020: 'PLACENAME',
475  106118: 'PLACENAME',
476  106499: 'PLACENAME'},
477 'City': {2869: 'BROOKLYN',
478  23571: 'NEW YORK',
479  41625: 'JAMAICA',
480  44331: 'JAMAICA',
481  46913: 'BROOKLYN',
482  47459: 'NEW YORK',
483  48465: 'JAMAICA',
484  51837: 'NEW YORK',
485  51848: 'NEW YORK',
486  54089: 'NEW YORK',
487  54343: 'NEW YORK',
488  55140: 'CORONA',
489  57789: 'EAST ELMHURST',
490  63119: 'JAMAICA',
491  66242: 'EAST ELMHURST',
492  66758: 'NEW YORK',
493  66786: 'NEW YORK',
494  66809: 'JAMAICA',
495  67465: 'FLUSHING',
496  72424: 'BROOKLYN',
497  75531: 'NEW YORK',
498  77918: 'NEW YORK',
499  78048: 'EAST ELMHURST',
500  78352: 'BROOKLYN',
501  78383: 'CORONA',
502  79078: 'NEW YORK',
503  84489: 'BROOKLYN',
504  84518: 'BROOKLYN',
505  84688: 'BROOKLYN',
506  84695: 'BROOKLYN',
507  88812: 'JAMAICA',
508  89205: 'NEW YORK',
509  89382: 'BROOKLYN',
510  89734: 'NEW YORK',
511  93990: 'NEW YORK',
512  99407: 'JAMAICA',
513  99847: 'NEW YORK',
514  100073: 'NEW YORK',
515  101013: 'NEW YORK',
516  104020: 'JAMAICA',
517  106118: 'NEW YORK',
518  106499: 'EAST ELMHURST'},
519 'Landmark': {2869: 'BARCLAYS CENTER',
520  23571: 'CENTRAL PARK',
521  41625: 'J F K AIRPORT',
522  44331: 'J F K AIRPORT',
523  46913: 'BARTEL PRITCHARD SQUARE',
524  47459: 'CITY COLLEGE',
525  48465: 'PS 37',
526  51837: 'JACKIE ROBINSON PARK',
527  51848: 'JACKIE ROBINSON PARK',
528  54089: 'CENTRAL PARK',
529  54343: 'UNION SQUARE PARK',
530  55140: 'WORLDS FAIR MARINA',
531  57789: 'LA GUARDIA AIRPORT',
532  63119: 'J F K AIRPORT',
533  66242: 'LA GUARDIA AIRPORT',
534  66758: 'BRYANT PARK',
535  66786: 'BETH ISRAEL MED CENTER',
536  66809: 'J F K AIRPORT',
537  67465: 'QUEENS COLLEGE',
538  72424: 'BARCLAYS CENTER',
539  75531: 'CENTRAL PARK',
540  77918: 'CENTRAL PARK',
541  78048: 'LA GUARDIA AIRPORT',
542  78352: 'BARCLAYS CENTER',
543  78383: 'WORLDS FAIR MARINA',
544  79078: 'WASHINGTON SQUARE PARK',
545  84489: 'PROSPECT PARK',
546  84518: 'PROSPECT PARK',
547  84688: 'PROSPECT PARK',
548  84695: 'PROSPECT PARK',
549  88812: 'J F K AIRPORT',
550  89205: 'CENTRAL PARK',
551  89382: 'GRAND ARMY PLAZA',
552  89734: 'BRYANT PARK',
553  93990: 'BETH ISRAEL MED CENTER',
554  99407: 'J F K AIRPORT',
555  99847: 'PORT AUTH 42 STREET',
556  100073: 'MUSEUM NATURAL HIST',
557  101013: 'GRAND CENTRAL TERM',
558  104020: 'JFK',
559  106118: 'CENTRAL PARK',
560  106499: 'LA GUARDIA AIRPORT'},
561 'Status': {2869: 'Closed',
562  23571: 'Closed',
563  41625: 'Closed',
564  44331: 'Closed',
565  46913: 'Closed',
566  47459: 'Closed',
567  48465: 'Closed',
568  51837: 'Closed',
569  51848: 'Closed',
570  54089: 'Closed',
571  54343: 'Closed',
572  55140: 'Closed',
573  57789: 'Closed',
574  63119: 'Closed',
575  66242: 'Closed',
576  66758: 'Closed',
577  66786: 'Closed',
578  66809: 'Closed',
579  67465: 'Closed',
580  72424: 'Closed',
581  75531: 'Closed',
582  77918: 'Closed',
583  78048: 'Closed',
584  78352: 'Closed',
585  78383: 'Closed',
586  79078: 'Closed',
587  84489: 'Closed',
588  84518: 'Closed',
589  84688: 'Closed',
590  84695: 'Closed',
591  88812: 'Closed',
592  89205: 'Closed',
593  89382: 'Closed',
594  89734: 'Closed',
595  93990: 'Closed',
596  99407: 'Closed',
597  99847: 'Closed',
598  100073: 'Closed',
599  101013: 'Closed',
600  104020: 'Closed',
601  106118: 'Closed',
602  106499: 'Closed'},
603 'Borough': {2869: 'BROOKLYN',
604  23571: 'MANHATTAN',
605  41625: 'QUEENS',
606  44331: 'QUEENS',
607  46913: 'BROOKLYN',
608  47459: 'MANHATTAN',
609  48465: 'QUEENS',
610  51837: 'MANHATTAN',
611  51848: 'MANHATTAN',
612  54089: 'MANHATTAN',
613  54343: 'MANHATTAN',
614  55140: 'QUEENS',
615  57789: 'QUEENS',
616  63119: 'QUEENS',
617  66242: 'QUEENS',
618  66758: 'MANHATTAN',
619  66786: 'MANHATTAN',
620  66809: 'QUEENS',
621  67465: 'QUEENS',
622  72424: 'BROOKLYN',
623  75531: 'MANHATTAN',
624  77918: 'MANHATTAN',
625  78048: 'QUEENS',
626  78352: 'BROOKLYN',
627  78383: 'QUEENS',
628  79078: 'MANHATTAN',
629  84489: 'BROOKLYN',
630  84518: 'BROOKLYN',
631  84688: 'BROOKLYN',
632  84695: 'BROOKLYN',
633  88812: 'QUEENS',
634  89205: 'MANHATTAN',
635  89382: 'BROOKLYN',
636  89734: 'MANHATTAN',
637  93990: 'MANHATTAN',
638  99407: 'QUEENS',
639  99847: 'MANHATTAN',
640  100073: 'MANHATTAN',
641  101013: 'MANHATTAN',
642  104020: 'QUEENS',
643  106118: 'MANHATTAN',
644  106499: 'QUEENS'}}
645for c in ['Created Date', 'Closed Date']:
646    df[c] = pd.to_datetime(df[c])
647    #df[c+'_date'] = df[c].dt.date # to extract the date (for created + closed)
648    #df[c+'_time'] = df[c].dt.time # to extract the time (for created + closed)
649

Then you can calculate the difference in time between the two as a new column (as hours) .astype('timedelta64[h]'), and then calculate a grouped mean:

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45                         mean                   count
46complaint Type           closing_time_hours     closing_time_hours
47Blocked Driveway         3.00                   4581
48DOF Literature Request   30.16                  5481
49General Construction     66.38                  798
50Heating                  54.88                  6704
51Illegal Parking          3.08                   3336
52Nonconst                 65                     100 
53Paint-Plaster            49                     3281 
54Plumbing                 65                     666   
55Strret Condition         81                     2610    
56Street Light Condition   90                     4207
57{'Unnamed: 0': {2869: 2869,
58  23571: 23571,
59  41625: 41625,
60  44331: 44331,
61  46913: 46913,
62  47459: 47459,
63  48465: 48465,
64  51837: 51837,
65  51848: 51848,
66  54089: 54089,
67  54343: 54343,
68  55140: 55140,
69  57789: 57789,
70  63119: 63119,
71  66242: 66242,
72  66758: 66758,
73  66786: 66786,
74  66809: 66809,
75  67465: 67465,
76  72424: 72424,
77  75531: 75531,
78  77918: 77918,
79  78048: 78048,
80  78352: 78352,
81  78383: 78383,
82  79078: 79078,
83  84489: 84489,
84  84518: 84518,
85  84688: 84688,
86  84695: 84695,
87  88812: 88812,
88  89205: 89205,
89  89382: 89382,
90  89734: 89734,
91  93990: 93990,
92  99407: 99407,
93  99847: 99847,
94  100073: 100073,
95  101013: 101013,
96  104020: 104020,
97  106118: 106118,
98  106499: 106499},
99 'Created Date': {2869: '10/30/2013 09:14:47 AM',
100  23571: '10/25/2013 02:33:54 PM',
101  41625: '10/22/2013 09:33:56 PM',
102  44331: '10/22/2013 07:25:35 AM',
103  46913: '10/21/2013 05:03:26 PM',
104  47459: '10/21/2013 02:56:08 PM',
105  48465: '10/21/2013 10:44:10 AM',
106  51837: '10/20/2013 04:36:12 PM',
107  51848: '10/20/2013 04:26:03 PM',
108  54089: '10/19/2013 03:45:47 PM',
109  54343: '10/19/2013 01:27:43 PM',
110  55140: '10/19/2013 02:02:28 AM',
111  57789: '10/18/2013 11:55:44 AM',
112  63119: '10/17/2013 06:52:37 AM',
113  66242: '10/16/2013 01:56:24 PM',
114  66758: '10/16/2013 11:52:43 AM',
115  66786: '10/16/2013 11:42:23 AM',
116  66809: '10/16/2013 11:36:54 AM',
117  67465: '10/16/2013 09:14:35 AM',
118  72424: '10/15/2013 12:22:00 AM',
119  75531: '10/14/2013 10:59:20 AM',
120  77918: '10/13/2013 03:16:03 PM',
121  78048: '10/13/2013 01:06:02 PM',
122  78352: '10/13/2013 05:14:33 AM',
123  78383: '10/13/2013 03:50:02 AM',
124  79078: '10/12/2013 09:53:17 PM',
125  84489: '10/10/2013 07:16:16 PM',
126  84518: '10/10/2013 07:02:29 PM',
127  84688: '10/10/2013 05:39:19 PM',
128  84695: '10/10/2013 05:37:04 PM',
129  88812: '10/09/2013 09:17:15 PM',
130  89205: '10/09/2013 06:01:48 PM',
131  89382: '10/09/2013 04:53:01 PM',
132  89734: '10/09/2013 03:13:23 PM',
133  93990: '10/08/2013 06:14:15 PM',
134  99407: '10/07/2013 03:56:11 PM',
135  99847: '10/07/2013 02:33:21 PM',
136  100073: '10/07/2013 01:36:02 PM',
137  101013: '10/07/2013 10:05:18 AM',
138  104020: '10/06/2013 02:58:47 PM',
139  106118: '10/05/2013 03:24:47 PM',
140  106499: '10/05/2013 11:52:13 AM'},
141 'Closed Date': {2869: '10/30/2013 10:48:51 AM',
142  23571: '10/25/2013 03:36:36 PM',
143  41625: '10/24/2013 05:37:24 PM',
144  44331: '10/25/2013 10:40:35 AM',
145  46913: '10/23/2013 09:59:23 AM',
146  47459: '10/29/2013 06:17:10 PM',
147  48465: '10/21/2013 11:17:47 AM',
148  51837: '10/20/2013 06:35:49 PM',
149  51848: '10/20/2013 06:34:47 PM',
150  54089: '10/19/2013 04:10:11 PM',
151  54343: '10/28/2013 08:42:12 AM',
152  55140: '10/19/2013 02:19:55 AM',
153  57789: '10/23/2013 02:42:14 PM',
154  63119: '10/25/2013 06:49:59 PM',
155  66242: '10/22/2013 03:09:11 PM',
156  66758: '10/16/2013 04:35:34 PM',
157  66786: '10/18/2013 04:57:04 PM',
158  66809: '10/16/2013 12:34:23 PM',
159  67465: '10/16/2013 12:43:06 PM',
160  72424: '10/21/2013 12:16:15 PM',
161  75531: '10/14/2013 03:09:51 PM',
162  77918: '10/13/2013 03:25:45 PM',
163  78048: '10/21/2013 10:20:21 AM',
164  78352: '10/16/2013 01:42:42 PM',
165  78383: '10/13/2013 05:03:13 AM',
166  79078: '10/13/2013 02:52:07 AM',
167  84489: '10/10/2013 10:29:16 PM',
168  84518: '10/10/2013 10:29:16 PM',
169  84688: '10/10/2013 10:29:17 PM',
170  84695: '10/10/2013 10:30:19 PM',
171  88812: '10/23/2013 02:15:21 PM',
172  89205: '10/09/2013 09:04:26 PM',
173  89382: '10/18/2013 08:35:02 AM',
174  89734: '10/09/2013 05:10:45 PM',
175  93990: '10/09/2013 04:00:59 PM',
176  99407: '10/08/2013 07:04:14 AM',
177  99847: '10/09/2013 02:36:42 PM',
178  100073: '10/09/2013 09:56:55 AM',
179  101013: '10/09/2013 03:36:23 PM',
180  104020: '10/07/2013 12:11:16 PM',
181  106118: '10/05/2013 04:20:34 PM',
182  106499: '10/07/2013 08:00:28 AM'},
183 'Agency': {2869: 'NYPD',
184  23571: 'NYPD',
185  41625: 'TLC',
186  44331: 'TLC',
187  46913: 'DPR',
188  47459: 'TLC',
189  48465: 'NYPD',
190  51837: 'NYPD',
191  51848: 'NYPD',
192  54089: 'NYPD',
193  54343: 'DOT',
194  55140: 'NYPD',
195  57789: 'TLC',
196  63119: 'TLC',
197  66242: 'TLC',
198  66758: 'NYPD',
199  66786: 'TLC',
200  66809: 'NYPD',
201  67465: 'NYPD',
202  72424: 'TLC',
203  75531: 'NYPD',
204  77918: 'NYPD',
205  78048: 'TLC',
206  78352: 'TLC',
207  78383: 'NYPD',
208  79078: 'NYPD',
209  84489: 'NYPD',
210  84518: 'NYPD',
211  84688: 'NYPD',
212  84695: 'NYPD',
213  88812: 'TLC',
214  89205: 'NYPD',
215  89382: 'DOT',
216  89734: 'NYPD',
217  93990: 'TLC',
218  99407: 'DPR',
219  99847: 'TLC',
220  100073: 'TLC',
221  101013: 'TLC',
222  104020: 'TLC',
223  106118: 'NYPD',
224  106499: 'DOT'},
225 'Agency Name': {2869: 'New York City Police Department',
226  23571: 'New York City Police Department',
227  41625: 'Taxi and Limousine Commission',
228  44331: 'Taxi and Limousine Commission',
229  46913: 'Department of Parks and Recreation',
230  47459: 'Taxi and Limousine Commission',
231  48465: 'New York City Police Department',
232  51837: 'New York City Police Department',
233  51848: 'New York City Police Department',
234  54089: 'New York City Police Department',
235  54343: 'Department of Transportation',
236  55140: 'New York City Police Department',
237  57789: 'Taxi and Limousine Commission',
238  63119: 'Taxi and Limousine Commission',
239  66242: 'Taxi and Limousine Commission',
240  66758: 'New York City Police Department',
241  66786: 'Taxi and Limousine Commission',
242  66809: 'New York City Police Department',
243  67465: 'New York City Police Department',
244  72424: 'Taxi and Limousine Commission',
245  75531: 'New York City Police Department',
246  77918: 'New York City Police Department',
247  78048: 'Taxi and Limousine Commission',
248  78352: 'Taxi and Limousine Commission',
249  78383: 'New York City Police Department',
250  79078: 'New York City Police Department',
251  84489: 'New York City Police Department',
252  84518: 'New York City Police Department',
253  84688: 'New York City Police Department',
254  84695: 'New York City Police Department',
255  88812: 'Taxi and Limousine Commission',
256  89205: 'New York City Police Department',
257  89382: 'Department of Transportation',
258  89734: 'New York City Police Department',
259  93990: 'Taxi and Limousine Commission',
260  99407: 'Department of Parks and Recreation',
261  99847: 'Taxi and Limousine Commission',
262  100073: 'Taxi and Limousine Commission',
263  101013: 'Taxi and Limousine Commission',
264  104020: 'Taxi and Limousine Commission',
265  106118: 'New York City Police Department',
266  106499: 'Department of Transportation'},
267 'Complaint Type': {2869: 'Illegal Parking',
268  23571: 'Noise - Park',
269  41625: 'For Hire Vehicle Complaint',
270  44331: 'Taxi Complaint',
271  46913: 'Dead Tree',
272  47459: 'Taxi Complaint',
273  48465: 'Illegal Parking',
274  51837: 'Noise - Park',
275  51848: 'Noise - Park',
276  54089: 'Noise - Park',
277  54343: 'Street Condition',
278  55140: 'Noise - Vehicle',
279  57789: 'Taxi Complaint',
280  63119: 'Taxi Complaint',
281  66242: 'Taxi Complaint',
282  66758: 'Vending',
283  66786: 'Taxi Complaint',
284  66809: 'Traffic',
285  67465: 'Traffic',
286  72424: 'Taxi Complaint',
287  75531: 'Vending',
288  77918: 'Noise - Park',
289  78048: 'Taxi Complaint',
290  78352: 'For Hire Vehicle Complaint',
291  78383: 'Noise - Vehicle',
292  79078: 'Noise - Park',
293  84489: 'Noise - Park',
294  84518: 'Noise - Park',
295  84688: 'Noise - Park',
296  84695: 'Noise - Park',
297  88812: 'Taxi Complaint',
298  89205: 'Vending',
299  89382: 'Public Toilet',
300  89734: 'Noise - Park',
301  93990: 'Taxi Complaint',
302  99407: 'Overgrown Tree/Branches',
303  99847: 'Taxi Complaint',
304  100073: 'Taxi Complaint',
305  101013: 'Taxi Complaint',
306  104020: 'For Hire Vehicle Complaint',
307  106118: 'Noise - Park',
308  106499: 'Public Toilet'},
309 'Descriptor': {2869: 'Double Parked Blocking Traffic',
310  23571: 'Loud Music/Party',
311  41625: 'Car Service Company Complaint',
312  44331: 'Driver Complaint',
313  46913: 'Dead/Dying Tree',
314  47459: 'Driver Complaint',
315  48465: 'Posted Parking Sign Violation',
316  51837: 'Loud Music/Party',
317  51848: 'Loud Music/Party',
318  54089: 'Loud Music/Party',
319  54343: 'Rough, Pitted or Cracked Roads',
320  55140: 'Car/Truck Music',
321  57789: 'Driver Complaint',
322  63119: 'Driver Complaint',
323  66242: 'Driver Complaint',
324  66758: 'Unlicensed',
325  66786: 'Insurance Information Requested',
326  66809: 'Congestion/Gridlock',
327  67465: 'Drag Racing',
328  72424: 'Driver Complaint',
329  75531: 'In Prohibited Area',
330  77918: 'Loud Music/Party',
331  78048: 'Driver Complaint',
332  78352: 'Car Service Company Complaint',
333  78383: 'Car/Truck Music',
334  79078: 'Loud Music/Party',
335  84489: 'Loud Music/Party',
336  84518: 'Loud Music/Party',
337  84688: 'Loud Music/Party',
338  84695: 'Loud Music/Party',
339  88812: 'Driver Complaint',
340  89205: 'Unlicensed',
341  89382: 'Damaged Door',
342  89734: 'Loud Music/Party',
343  93990: 'Driver Complaint',
344  99407: 'Traffic Sign or Signal Blocked',
345  99847: 'Driver Complaint',
346  100073: 'Driver Complaint',
347  101013: 'Driver Complaint',
348  104020: 'Car Service Company Complaint',
349  106118: 'Loud Music/Party',
350  106499: 'Dirty/Graffiti'},
351 'Location Type': {2869: 'Street/Sidewalk',
352  23571: 'Park/Playground',
353  41625: 'Street',
354  44331: 'Street',
355  46913: 'Street',
356  47459: 'Street',
357  48465: 'Street/Sidewalk',
358  51837: 'Park/Playground',
359  51848: 'Park/Playground',
360  54089: 'Park/Playground',
361  54343: 'Street',
362  55140: 'Street/Sidewalk',
363  57789: 'Street',
364  63119: 'Street',
365  66242: 'Street',
366  66758: 'Park/Playground',
367  66786: 'Street',
368  66809: 'Street/Sidewalk',
369  67465: 'Street/Sidewalk',
370  72424: 'Street',
371  75531: 'Park/Playground',
372  77918: 'Park/Playground',
373  78048: 'Street',
374  78352: 'Street',
375  78383: 'Street/Sidewalk',
376  79078: 'Park/Playground',
377  84489: 'Park/Playground',
378  84518: 'Park/Playground',
379  84688: 'Park/Playground',
380  84695: 'Park/Playground',
381  88812: 'Street',
382  89205: 'Park/Playground',
383  89382: 'Sidewalk',
384  89734: 'Park/Playground',
385  93990: 'Street',
386  99407: 'Street',
387  99847: 'Street',
388  100073: 'Street',
389  101013: 'Street',
390  104020: 'Street',
391  106118: 'Park/Playground',
392  106499: 'Sidewalk'},
393 'Incident Zip': {2869: '11217.0',
394  23571: '10000',
395  41625: '11430',
396  44331: '11430',
397  46913: '11215',
398  47459: '10031',
399  48465: '11434',
400  51837: '10031.0',
401  51848: '10031.0',
402  54089: '10000.0',
403  54343: '10003.0',
404  55140: '11368.0',
405  57789: '11369.0',
406  63119: '11430.0',
407  66242: '11369',
408  66758: '10036',
409  66786: '10003',
410  66809: '11430',
411  67465: '11367',
412  72424: '11217',
413  75531: '10000',
414  77918: '10000',
415  78048: '11369',
416  78352: '11217',
417  78383: '11368',
418  79078: '10011',
419  84489: '11215',
420  84518: '11215',
421  84688: '11215',
422  84695: '11215',
423  88812: '11430',
424  89205: '10000',
425  89382: '11238',
426  89734: '10036',
427  93990: '10003',
428  99407: '11430.0',
429  99847: '10036.0',
430  100073: '10024.0',
431  101013: '10017.0',
432  104020: '11430.0',
433  106118: '10000.0',
434  106499: '11369.0'},
435 'Address Type': {2869: 'PLACENAME',
436  23571: 'PLACENAME',
437  41625: 'PLACENAME',
438  44331: 'PLACENAME',
439  46913: 'PLACENAME',
440  47459: 'PLACENAME',
441  48465: 'PLACENAME',
442  51837: 'PLACENAME',
443  51848: 'PLACENAME',
444  54089: 'PLACENAME',
445  54343: 'PLACENAME',
446  55140: 'PLACENAME',
447  57789: 'PLACENAME',
448  63119: 'PLACENAME',
449  66242: 'PLACENAME',
450  66758: 'PLACENAME',
451  66786: 'PLACENAME',
452  66809: 'PLACENAME',
453  67465: 'PLACENAME',
454  72424: 'PLACENAME',
455  75531: 'PLACENAME',
456  77918: 'PLACENAME',
457  78048: 'PLACENAME',
458  78352: 'PLACENAME',
459  78383: 'PLACENAME',
460  79078: 'PLACENAME',
461  84489: 'PLACENAME',
462  84518: 'PLACENAME',
463  84688: 'PLACENAME',
464  84695: 'PLACENAME',
465  88812: 'PLACENAME',
466  89205: 'PLACENAME',
467  89382: 'PLACENAME',
468  89734: 'PLACENAME',
469  93990: 'PLACENAME',
470  99407: 'PLACENAME',
471  99847: 'PLACENAME',
472  100073: 'PLACENAME',
473  101013: 'PLACENAME',
474  104020: 'PLACENAME',
475  106118: 'PLACENAME',
476  106499: 'PLACENAME'},
477 'City': {2869: 'BROOKLYN',
478  23571: 'NEW YORK',
479  41625: 'JAMAICA',
480  44331: 'JAMAICA',
481  46913: 'BROOKLYN',
482  47459: 'NEW YORK',
483  48465: 'JAMAICA',
484  51837: 'NEW YORK',
485  51848: 'NEW YORK',
486  54089: 'NEW YORK',
487  54343: 'NEW YORK',
488  55140: 'CORONA',
489  57789: 'EAST ELMHURST',
490  63119: 'JAMAICA',
491  66242: 'EAST ELMHURST',
492  66758: 'NEW YORK',
493  66786: 'NEW YORK',
494  66809: 'JAMAICA',
495  67465: 'FLUSHING',
496  72424: 'BROOKLYN',
497  75531: 'NEW YORK',
498  77918: 'NEW YORK',
499  78048: 'EAST ELMHURST',
500  78352: 'BROOKLYN',
501  78383: 'CORONA',
502  79078: 'NEW YORK',
503  84489: 'BROOKLYN',
504  84518: 'BROOKLYN',
505  84688: 'BROOKLYN',
506  84695: 'BROOKLYN',
507  88812: 'JAMAICA',
508  89205: 'NEW YORK',
509  89382: 'BROOKLYN',
510  89734: 'NEW YORK',
511  93990: 'NEW YORK',
512  99407: 'JAMAICA',
513  99847: 'NEW YORK',
514  100073: 'NEW YORK',
515  101013: 'NEW YORK',
516  104020: 'JAMAICA',
517  106118: 'NEW YORK',
518  106499: 'EAST ELMHURST'},
519 'Landmark': {2869: 'BARCLAYS CENTER',
520  23571: 'CENTRAL PARK',
521  41625: 'J F K AIRPORT',
522  44331: 'J F K AIRPORT',
523  46913: 'BARTEL PRITCHARD SQUARE',
524  47459: 'CITY COLLEGE',
525  48465: 'PS 37',
526  51837: 'JACKIE ROBINSON PARK',
527  51848: 'JACKIE ROBINSON PARK',
528  54089: 'CENTRAL PARK',
529  54343: 'UNION SQUARE PARK',
530  55140: 'WORLDS FAIR MARINA',
531  57789: 'LA GUARDIA AIRPORT',
532  63119: 'J F K AIRPORT',
533  66242: 'LA GUARDIA AIRPORT',
534  66758: 'BRYANT PARK',
535  66786: 'BETH ISRAEL MED CENTER',
536  66809: 'J F K AIRPORT',
537  67465: 'QUEENS COLLEGE',
538  72424: 'BARCLAYS CENTER',
539  75531: 'CENTRAL PARK',
540  77918: 'CENTRAL PARK',
541  78048: 'LA GUARDIA AIRPORT',
542  78352: 'BARCLAYS CENTER',
543  78383: 'WORLDS FAIR MARINA',
544  79078: 'WASHINGTON SQUARE PARK',
545  84489: 'PROSPECT PARK',
546  84518: 'PROSPECT PARK',
547  84688: 'PROSPECT PARK',
548  84695: 'PROSPECT PARK',
549  88812: 'J F K AIRPORT',
550  89205: 'CENTRAL PARK',
551  89382: 'GRAND ARMY PLAZA',
552  89734: 'BRYANT PARK',
553  93990: 'BETH ISRAEL MED CENTER',
554  99407: 'J F K AIRPORT',
555  99847: 'PORT AUTH 42 STREET',
556  100073: 'MUSEUM NATURAL HIST',
557  101013: 'GRAND CENTRAL TERM',
558  104020: 'JFK',
559  106118: 'CENTRAL PARK',
560  106499: 'LA GUARDIA AIRPORT'},
561 'Status': {2869: 'Closed',
562  23571: 'Closed',
563  41625: 'Closed',
564  44331: 'Closed',
565  46913: 'Closed',
566  47459: 'Closed',
567  48465: 'Closed',
568  51837: 'Closed',
569  51848: 'Closed',
570  54089: 'Closed',
571  54343: 'Closed',
572  55140: 'Closed',
573  57789: 'Closed',
574  63119: 'Closed',
575  66242: 'Closed',
576  66758: 'Closed',
577  66786: 'Closed',
578  66809: 'Closed',
579  67465: 'Closed',
580  72424: 'Closed',
581  75531: 'Closed',
582  77918: 'Closed',
583  78048: 'Closed',
584  78352: 'Closed',
585  78383: 'Closed',
586  79078: 'Closed',
587  84489: 'Closed',
588  84518: 'Closed',
589  84688: 'Closed',
590  84695: 'Closed',
591  88812: 'Closed',
592  89205: 'Closed',
593  89382: 'Closed',
594  89734: 'Closed',
595  93990: 'Closed',
596  99407: 'Closed',
597  99847: 'Closed',
598  100073: 'Closed',
599  101013: 'Closed',
600  104020: 'Closed',
601  106118: 'Closed',
602  106499: 'Closed'},
603 'Borough': {2869: 'BROOKLYN',
604  23571: 'MANHATTAN',
605  41625: 'QUEENS',
606  44331: 'QUEENS',
607  46913: 'BROOKLYN',
608  47459: 'MANHATTAN',
609  48465: 'QUEENS',
610  51837: 'MANHATTAN',
611  51848: 'MANHATTAN',
612  54089: 'MANHATTAN',
613  54343: 'MANHATTAN',
614  55140: 'QUEENS',
615  57789: 'QUEENS',
616  63119: 'QUEENS',
617  66242: 'QUEENS',
618  66758: 'MANHATTAN',
619  66786: 'MANHATTAN',
620  66809: 'QUEENS',
621  67465: 'QUEENS',
622  72424: 'BROOKLYN',
623  75531: 'MANHATTAN',
624  77918: 'MANHATTAN',
625  78048: 'QUEENS',
626  78352: 'BROOKLYN',
627  78383: 'QUEENS',
628  79078: 'MANHATTAN',
629  84489: 'BROOKLYN',
630  84518: 'BROOKLYN',
631  84688: 'BROOKLYN',
632  84695: 'BROOKLYN',
633  88812: 'QUEENS',
634  89205: 'MANHATTAN',
635  89382: 'BROOKLYN',
636  89734: 'MANHATTAN',
637  93990: 'MANHATTAN',
638  99407: 'QUEENS',
639  99847: 'MANHATTAN',
640  100073: 'MANHATTAN',
641  101013: 'MANHATTAN',
642  104020: 'QUEENS',
643  106118: 'MANHATTAN',
644  106499: 'QUEENS'}}
645for c in ['Created Date', 'Closed Date']:
646    df[c] = pd.to_datetime(df[c])
647    #df[c+'_date'] = df[c].dt.date # to extract the date (for created + closed)
648    #df[c+'_time'] = df[c].dt.time # to extract the time (for created + closed)
649df['difference in time'] = (df['Closed Date'] - df['Created Date']).astype('timedelta64[h]')
650print(df.groupby('Complaint Type').agg({'difference in time':'mean'}))
651

returns:

1Unnamed: 0     Created Date             Closed Date            Agency   Agency Name  Complaint Type Descriptor  Location Type   Incident Zip    Address Type    City    Landmark    Status  Borough
22869    2869    10/30/2013 09:14:47 AM  10/30/2013 10:48:51 AM  NYPD    New York City Police Department Illegal Parking Double Parked Blocking Traffic  Street/Sidewalk 11217.0 PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
323571   23571   10/25/2013 02:33:54 PM  10/25/2013 03:36:36 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
441625   41625   10/22/2013 09:33:56 PM  10/24/2013 05:37:24 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
544331   44331   10/22/2013 07:25:35 AM  10/25/2013 10:40:35 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
646913   46913   10/21/2013 05:03:26 PM  10/23/2013 09:59:23 AM  DPR Department of Parks and Recreation  Dead Tree   Dead/Dying Tree Street  11215   PLACENAME   BROOKLYN    BARTEL PRITCHARD SQUARE Closed  BROOKLYN
747459   47459   10/21/2013 02:56:08 PM  10/29/2013 06:17:10 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10031   PLACENAME   NEW YORK    CITY COLLEGE    Closed  MANHATTAN
848465   48465   10/21/2013 10:44:10 AM  10/21/2013 11:17:47 AM  NYPD    New York City Police Department Illegal Parking Posted Parking Sign Violation   Street/Sidewalk 11434   PLACENAME   JAMAICA PS 37   Closed  QUEENS
951837   51837   10/20/2013 04:36:12 PM  10/20/2013 06:35:49 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1051848   51848   10/20/2013 04:26:03 PM  10/20/2013 06:34:47 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10031.0 PLACENAME   NEW YORK    JACKIE ROBINSON PARK    Closed  MANHATTAN
1154089   54089   10/19/2013 03:45:47 PM  10/19/2013 04:10:11 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
1254343   54343   10/19/2013 01:27:43 PM  10/28/2013 08:42:12 AM  DOT Department of Transportation    Street Condition    Rough, Pitted or Cracked Roads  Street  10003.0 PLACENAME   NEW YORK    UNION SQUARE PARK   Closed  MANHATTAN
1355140   55140   10/19/2013 02:02:28 AM  10/19/2013 02:19:55 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368.0 PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
1457789   57789   10/18/2013 11:55:44 AM  10/23/2013 02:42:14 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1563119   63119   10/17/2013 06:52:37 AM  10/25/2013 06:49:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
1666242   66242   10/16/2013 01:56:24 PM  10/22/2013 03:09:11 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
1766758   66758   10/16/2013 11:52:43 AM  10/16/2013 04:35:34 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
1866786   66786   10/16/2013 11:42:23 AM  10/18/2013 04:57:04 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Insurance Information Requested Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
1966809   66809   10/16/2013 11:36:54 AM  10/16/2013 12:34:23 PM  NYPD    New York City Police Department Traffic Congestion/Gridlock Street/Sidewalk 11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
2067465   67465   10/16/2013 09:14:35 AM  10/16/2013 12:43:06 PM  NYPD    New York City Police Department Traffic Drag Racing Street/Sidewalk 11367   PLACENAME   FLUSHING    QUEENS COLLEGE  Closed  QUEENS
2172424   72424   10/15/2013 12:22:00 AM  10/21/2013 12:16:15 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2275531   75531   10/14/2013 10:59:20 AM  10/14/2013 03:09:51 PM  NYPD    New York City Police Department Vending In Prohibited Area  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2377918   77918   10/13/2013 03:16:03 PM  10/13/2013 03:25:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
2478048   78048   10/13/2013 01:06:02 PM  10/21/2013 10:20:21 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11369   PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
2578352   78352   10/13/2013 05:14:33 AM  10/16/2013 01:42:42 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11217   PLACENAME   BROOKLYN    BARCLAYS CENTER Closed  BROOKLYN
2678383   78383   10/13/2013 03:50:02 AM  10/13/2013 05:03:13 AM  NYPD    New York City Police Department Noise - Vehicle Car/Truck Music Street/Sidewalk 11368   PLACENAME   CORONA  WORLDS FAIR MARINA  Closed  QUEENS
2779078   79078   10/12/2013 09:53:17 PM  10/13/2013 02:52:07 AM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10011   PLACENAME   NEW YORK    WASHINGTON SQUARE PARK  Closed  MANHATTAN
2884489   84489   10/10/2013 07:16:16 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
2984518   84518   10/10/2013 07:02:29 PM  10/10/2013 10:29:16 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3084688   84688   10/10/2013 05:39:19 PM  10/10/2013 10:29:17 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3184695   84695   10/10/2013 05:37:04 PM  10/10/2013 10:30:19 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 11215   PLACENAME   BROOKLYN    PROSPECT PARK   Closed  BROOKLYN
3288812   88812   10/09/2013 09:17:15 PM  10/23/2013 02:15:21 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  11430   PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3389205   89205   10/09/2013 06:01:48 PM  10/09/2013 09:04:26 PM  NYPD    New York City Police Department Vending Unlicensed  Park/Playground 10000   PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
3489382   89382   10/09/2013 04:53:01 PM  10/18/2013 08:35:02 AM  DOT Department of Transportation    Public Toilet   Damaged Door    Sidewalk    11238   PLACENAME   BROOKLYN    GRAND ARMY PLAZA    Closed  BROOKLYN
3589734   89734   10/09/2013 03:13:23 PM  10/09/2013 05:10:45 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10036   PLACENAME   NEW YORK    BRYANT PARK Closed  MANHATTAN
3693990   93990   10/08/2013 06:14:15 PM  10/09/2013 04:00:59 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10003   PLACENAME   NEW YORK    BETH ISRAEL MED CENTER  Closed  MANHATTAN
3799407   99407   10/07/2013 03:56:11 PM  10/08/2013 07:04:14 AM  DPR Department of Parks and Recreation  Overgrown Tree/Branches Traffic Sign or Signal Blocked  Street  11430.0 PLACENAME   JAMAICA J F K AIRPORT   Closed  QUEENS
3899847   99847   10/07/2013 02:33:21 PM  10/09/2013 02:36:42 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10036.0 PLACENAME   NEW YORK    PORT AUTH 42 STREET Closed  MANHATTAN
39100073  100073  10/07/2013 01:36:02 PM  10/09/2013 09:56:55 AM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10024.0 PLACENAME   NEW YORK    MUSEUM NATURAL HIST Closed  MANHATTAN
40101013  101013  10/07/2013 10:05:18 AM  10/09/2013 03:36:23 PM  TLC Taxi and Limousine Commission   Taxi Complaint  Driver Complaint    Street  10017.0 PLACENAME   NEW YORK    GRAND CENTRAL TERM  Closed  MANHATTAN
41104020  104020  10/06/2013 02:58:47 PM  10/07/2013 12:11:16 PM  TLC Taxi and Limousine Commission   For Hire Vehicle Complaint  Car Service Company Complaint   Street  11430.0 PLACENAME   JAMAICA JFK Closed  QUEENS
42106118  106118  10/05/2013 03:24:47 PM  10/05/2013 04:20:34 PM  NYPD    New York City Police Department Noise - Park    Loud Music/Party    Park/Playground 10000.0 PLACENAME   NEW YORK    CENTRAL PARK    Closed  MANHATTAN
43106499  106499  10/05/2013 11:52:13 AM  10/07/2013 08:00:28 AM  DOT Department of Transportation    Public Toilet   Dirty/Graffiti  Sidewalk    11369.0 PLACENAME   EAST ELMHURST   LA GUARDIA AIRPORT  Closed  QUEENS
44pd.Timedelta(task3['Closed Date'] - task3['Created Date']).seconds / 60.0
45                         mean                   count
46complaint Type           closing_time_hours     closing_time_hours
47Blocked Driveway         3.00                   4581
48DOF Literature Request   30.16                  5481
49General Construction     66.38                  798
50Heating                  54.88                  6704
51Illegal Parking          3.08                   3336
52Nonconst                 65                     100 
53Paint-Plaster            49                     3281 
54Plumbing                 65                     666   
55Strret Condition         81                     2610    
56Street Light Condition   90                     4207
57{'Unnamed: 0': {2869: 2869,
58  23571: 23571,
59  41625: 41625,
60  44331: 44331,
61  46913: 46913,
62  47459: 47459,
63  48465: 48465,
64  51837: 51837,
65  51848: 51848,
66  54089: 54089,
67  54343: 54343,
68  55140: 55140,
69  57789: 57789,
70  63119: 63119,
71  66242: 66242,
72  66758: 66758,
73  66786: 66786,
74  66809: 66809,
75  67465: 67465,
76  72424: 72424,
77  75531: 75531,
78  77918: 77918,
79  78048: 78048,
80  78352: 78352,
81  78383: 78383,
82  79078: 79078,
83  84489: 84489,
84  84518: 84518,
85  84688: 84688,
86  84695: 84695,
87  88812: 88812,
88  89205: 89205,
89  89382: 89382,
90  89734: 89734,
91  93990: 93990,
92  99407: 99407,
93  99847: 99847,
94  100073: 100073,
95  101013: 101013,
96  104020: 104020,
97  106118: 106118,
98  106499: 106499},
99 'Created Date': {2869: '10/30/2013 09:14:47 AM',
100  23571: '10/25/2013 02:33:54 PM',
101  41625: '10/22/2013 09:33:56 PM',
102  44331: '10/22/2013 07:25:35 AM',
103  46913: '10/21/2013 05:03:26 PM',
104  47459: '10/21/2013 02:56:08 PM',
105  48465: '10/21/2013 10:44:10 AM',
106  51837: '10/20/2013 04:36:12 PM',
107  51848: '10/20/2013 04:26:03 PM',
108  54089: '10/19/2013 03:45:47 PM',
109  54343: '10/19/2013 01:27:43 PM',
110  55140: '10/19/2013 02:02:28 AM',
111  57789: '10/18/2013 11:55:44 AM',
112  63119: '10/17/2013 06:52:37 AM',
113  66242: '10/16/2013 01:56:24 PM',
114  66758: '10/16/2013 11:52:43 AM',
115  66786: '10/16/2013 11:42:23 AM',
116  66809: '10/16/2013 11:36:54 AM',
117  67465: '10/16/2013 09:14:35 AM',
118  72424: '10/15/2013 12:22:00 AM',
119  75531: '10/14/2013 10:59:20 AM',
120  77918: '10/13/2013 03:16:03 PM',
121  78048: '10/13/2013 01:06:02 PM',
122  78352: '10/13/2013 05:14:33 AM',
123  78383: '10/13/2013 03:50:02 AM',
124  79078: '10/12/2013 09:53:17 PM',
125  84489: '10/10/2013 07:16:16 PM',
126  84518: '10/10/2013 07:02:29 PM',
127  84688: '10/10/2013 05:39:19 PM',
128  84695: '10/10/2013 05:37:04 PM',
129  88812: '10/09/2013 09:17:15 PM',
130  89205: '10/09/2013 06:01:48 PM',
131  89382: '10/09/2013 04:53:01 PM',
132  89734: '10/09/2013 03:13:23 PM',
133  93990: '10/08/2013 06:14:15 PM',
134  99407: '10/07/2013 03:56:11 PM',
135  99847: '10/07/2013 02:33:21 PM',
136  100073: '10/07/2013 01:36:02 PM',
137  101013: '10/07/2013 10:05:18 AM',
138  104020: '10/06/2013 02:58:47 PM',
139  106118: '10/05/2013 03:24:47 PM',
140  106499: '10/05/2013 11:52:13 AM'},
141 'Closed Date': {2869: '10/30/2013 10:48:51 AM',
142  23571: '10/25/2013 03:36:36 PM',
143  41625: '10/24/2013 05:37:24 PM',
144  44331: '10/25/2013 10:40:35 AM',
145  46913: '10/23/2013 09:59:23 AM',
146  47459: '10/29/2013 06:17:10 PM',
147  48465: '10/21/2013 11:17:47 AM',
148  51837: '10/20/2013 06:35:49 PM',
149  51848: '10/20/2013 06:34:47 PM',
150  54089: '10/19/2013 04:10:11 PM',
151  54343: '10/28/2013 08:42:12 AM',
152  55140: '10/19/2013 02:19:55 AM',
153  57789: '10/23/2013 02:42:14 PM',
154  63119: '10/25/2013 06:49:59 PM',
155  66242: '10/22/2013 03:09:11 PM',
156  66758: '10/16/2013 04:35:34 PM',
157  66786: '10/18/2013 04:57:04 PM',
158  66809: '10/16/2013 12:34:23 PM',
159  67465: '10/16/2013 12:43:06 PM',
160  72424: '10/21/2013 12:16:15 PM',
161  75531: '10/14/2013 03:09:51 PM',
162  77918: '10/13/2013 03:25:45 PM',
163  78048: '10/21/2013 10:20:21 AM',
164  78352: '10/16/2013 01:42:42 PM',
165  78383: '10/13/2013 05:03:13 AM',
166  79078: '10/13/2013 02:52:07 AM',
167  84489: '10/10/2013 10:29:16 PM',
168  84518: '10/10/2013 10:29:16 PM',
169  84688: '10/10/2013 10:29:17 PM',
170  84695: '10/10/2013 10:30:19 PM',
171  88812: '10/23/2013 02:15:21 PM',
172  89205: '10/09/2013 09:04:26 PM',
173  89382: '10/18/2013 08:35:02 AM',
174  89734: '10/09/2013 05:10:45 PM',
175  93990: '10/09/2013 04:00:59 PM',
176  99407: '10/08/2013 07:04:14 AM',
177  99847: '10/09/2013 02:36:42 PM',
178  100073: '10/09/2013 09:56:55 AM',
179  101013: '10/09/2013 03:36:23 PM',
180  104020: '10/07/2013 12:11:16 PM',
181  106118: '10/05/2013 04:20:34 PM',
182  106499: '10/07/2013 08:00:28 AM'},
183 'Agency': {2869: 'NYPD',
184  23571: 'NYPD',
185  41625: 'TLC',
186  44331: 'TLC',
187  46913: 'DPR',
188  47459: 'TLC',
189  48465: 'NYPD',
190  51837: 'NYPD',
191  51848: 'NYPD',
192  54089: 'NYPD',
193  54343: 'DOT',
194  55140: 'NYPD',
195  57789: 'TLC',
196  63119: 'TLC',
197  66242: 'TLC',
198  66758: 'NYPD',
199  66786: 'TLC',
200  66809: 'NYPD',
201  67465: 'NYPD',
202  72424: 'TLC',
203  75531: 'NYPD',
204  77918: 'NYPD',
205  78048: 'TLC',
206  78352: 'TLC',
207  78383: 'NYPD',
208  79078: 'NYPD',
209  84489: 'NYPD',
210  84518: 'NYPD',
211  84688: 'NYPD',
212  84695: 'NYPD',
213  88812: 'TLC',
214  89205: 'NYPD',
215  89382: 'DOT',
216  89734: 'NYPD',
217  93990: 'TLC',
218  99407: 'DPR',
219  99847: 'TLC',
220  100073: 'TLC',
221  101013: 'TLC',
222  104020: 'TLC',
223  106118: 'NYPD',
224  106499: 'DOT'},
225 'Agency Name': {2869: 'New York City Police Department',
226  23571: 'New York City Police Department',
227  41625: 'Taxi and Limousine Commission',
228  44331: 'Taxi and Limousine Commission',
229  46913: 'Department of Parks and Recreation',
230  47459: 'Taxi and Limousine Commission',
231  48465: 'New York City Police Department',
232  51837: 'New York City Police Department',
233  51848: 'New York City Police Department',
234  54089: 'New York City Police Department',
235  54343: 'Department of Transportation',
236  55140: 'New York City Police Department',
237  57789: 'Taxi and Limousine Commission',
238  63119: 'Taxi and Limousine Commission',
239  66242: 'Taxi and Limousine Commission',
240  66758: 'New York City Police Department',
241  66786: 'Taxi and Limousine Commission',
242  66809: 'New York City Police Department',
243  67465: 'New York City Police Department',
244  72424: 'Taxi and Limousine Commission',
245  75531: 'New York City Police Department',
246  77918: 'New York City Police Department',
247  78048: 'Taxi and Limousine Commission',
248  78352: 'Taxi and Limousine Commission',
249  78383: 'New York City Police Department',
250  79078: 'New York City Police Department',
251  84489: 'New York City Police Department',
252  84518: 'New York City Police Department',
253  84688: 'New York City Police Department',
254  84695: 'New York City Police Department',
255  88812: 'Taxi and Limousine Commission',
256  89205: 'New York City Police Department',
257  89382: 'Department of Transportation',
258  89734: 'New York City Police Department',
259  93990: 'Taxi and Limousine Commission',
260  99407: 'Department of Parks and Recreation',
261  99847: 'Taxi and Limousine Commission',
262  100073: 'Taxi and Limousine Commission',
263  101013: 'Taxi and Limousine Commission',
264  104020: 'Taxi and Limousine Commission',
265  106118: 'New York City Police Department',
266  106499: 'Department of Transportation'},
267 'Complaint Type': {2869: 'Illegal Parking',
268  23571: 'Noise - Park',
269  41625: 'For Hire Vehicle Complaint',
270  44331: 'Taxi Complaint',
271  46913: 'Dead Tree',
272  47459: 'Taxi Complaint',
273  48465: 'Illegal Parking',
274  51837: 'Noise - Park',
275  51848: 'Noise - Park',
276  54089: 'Noise - Park',
277  54343: 'Street Condition',
278  55140: 'Noise - Vehicle',
279  57789: 'Taxi Complaint',
280  63119: 'Taxi Complaint',
281  66242: 'Taxi Complaint',
282  66758: 'Vending',
283  66786: 'Taxi Complaint',
284  66809: 'Traffic',
285  67465: 'Traffic',
286  72424: 'Taxi Complaint',
287  75531: 'Vending',
288  77918: 'Noise - Park',
289  78048: 'Taxi Complaint',
290  78352: 'For Hire Vehicle Complaint',
291  78383: 'Noise - Vehicle',
292  79078: 'Noise - Park',
293  84489: 'Noise - Park',
294  84518: 'Noise - Park',
295  84688: 'Noise - Park',
296  84695: 'Noise - Park',
297  88812: 'Taxi Complaint',
298  89205: 'Vending',
299  89382: 'Public Toilet',
300  89734: 'Noise - Park',
301  93990: 'Taxi Complaint',
302  99407: 'Overgrown Tree/Branches',
303  99847: 'Taxi Complaint',
304  100073: 'Taxi Complaint',
305  101013: 'Taxi Complaint',
306  104020: 'For Hire Vehicle Complaint',
307  106118: 'Noise - Park',
308  106499: 'Public Toilet'},
309 'Descriptor': {2869: 'Double Parked Blocking Traffic',
310  23571: 'Loud Music/Party',
311  41625: 'Car Service Company Complaint',
312  44331: 'Driver Complaint',
313  46913: 'Dead/Dying Tree',
314  47459: 'Driver Complaint',
315  48465: 'Posted Parking Sign Violation',
316  51837: 'Loud Music/Party',
317  51848: 'Loud Music/Party',
318  54089: 'Loud Music/Party',
319  54343: 'Rough, Pitted or Cracked Roads',
320  55140: 'Car/Truck Music',
321  57789: 'Driver Complaint',
322  63119: 'Driver Complaint',
323  66242: 'Driver Complaint',
324  66758: 'Unlicensed',
325  66786: 'Insurance Information Requested',
326  66809: 'Congestion/Gridlock',
327  67465: 'Drag Racing',
328  72424: 'Driver Complaint',
329  75531: 'In Prohibited Area',
330  77918: 'Loud Music/Party',
331  78048: 'Driver Complaint',
332  78352: 'Car Service Company Complaint',
333  78383: 'Car/Truck Music',
334  79078: 'Loud Music/Party',
335  84489: 'Loud Music/Party',
336  84518: 'Loud Music/Party',
337  84688: 'Loud Music/Party',
338  84695: 'Loud Music/Party',
339  88812: 'Driver Complaint',
340  89205: 'Unlicensed',
341  89382: 'Damaged Door',
342  89734: 'Loud Music/Party',
343  93990: 'Driver Complaint',
344  99407: 'Traffic Sign or Signal Blocked',
345  99847: 'Driver Complaint',
346  100073: 'Driver Complaint',
347  101013: 'Driver Complaint',
348  104020: 'Car Service Company Complaint',
349  106118: 'Loud Music/Party',
350  106499: 'Dirty/Graffiti'},
351 'Location Type': {2869: 'Street/Sidewalk',
352  23571: 'Park/Playground',
353  41625: 'Street',
354  44331: 'Street',
355  46913: 'Street',
356  47459: 'Street',
357  48465: 'Street/Sidewalk',
358  51837: 'Park/Playground',
359  51848: 'Park/Playground',
360  54089: 'Park/Playground',
361  54343: 'Street',
362  55140: 'Street/Sidewalk',
363  57789: 'Street',
364  63119: 'Street',
365  66242: 'Street',
366  66758: 'Park/Playground',
367  66786: 'Street',
368  66809: 'Street/Sidewalk',
369  67465: 'Street/Sidewalk',
370  72424: 'Street',
371  75531: 'Park/Playground',
372  77918: 'Park/Playground',
373  78048: 'Street',
374  78352: 'Street',
375  78383: 'Street/Sidewalk',
376  79078: 'Park/Playground',
377  84489: 'Park/Playground',
378  84518: 'Park/Playground',
379  84688: 'Park/Playground',
380  84695: 'Park/Playground',
381  88812: 'Street',
382  89205: 'Park/Playground',
383  89382: 'Sidewalk',
384  89734: 'Park/Playground',
385  93990: 'Street',
386  99407: 'Street',
387  99847: 'Street',
388  100073: 'Street',
389  101013: 'Street',
390  104020: 'Street',
391  106118: 'Park/Playground',
392  106499: 'Sidewalk'},
393 'Incident Zip': {2869: '11217.0',
394  23571: '10000',
395  41625: '11430',
396  44331: '11430',
397  46913: '11215',
398  47459: '10031',
399  48465: '11434',
400  51837: '10031.0',
401  51848: '10031.0',
402  54089: '10000.0',
403  54343: '10003.0',
404  55140: '11368.0',
405  57789: '11369.0',
406  63119: '11430.0',
407  66242: '11369',
408  66758: '10036',
409  66786: '10003',
410  66809: '11430',
411  67465: '11367',
412  72424: '11217',
413  75531: '10000',
414  77918: '10000',
415  78048: '11369',
416  78352: '11217',
417  78383: '11368',
418  79078: '10011',
419  84489: '11215',
420  84518: '11215',
421  84688: '11215',
422  84695: '11215',
423  88812: '11430',
424  89205: '10000',
425  89382: '11238',
426  89734: '10036',
427  93990: '10003',
428  99407: '11430.0',
429  99847: '10036.0',
430  100073: '10024.0',
431  101013: '10017.0',
432  104020: '11430.0',
433  106118: '10000.0',
434  106499: '11369.0'},
435 'Address Type': {2869: 'PLACENAME',
436  23571: 'PLACENAME',
437  41625: 'PLACENAME',
438  44331: 'PLACENAME',
439  46913: 'PLACENAME',
440  47459: 'PLACENAME',
441  48465: 'PLACENAME',
442  51837: 'PLACENAME',
443  51848: 'PLACENAME',
444  54089: 'PLACENAME',
445  54343: 'PLACENAME',
446  55140: 'PLACENAME',
447  57789: 'PLACENAME',
448  63119: 'PLACENAME',
449  66242: 'PLACENAME',
450  66758: 'PLACENAME',
451  66786: 'PLACENAME',
452  66809: 'PLACENAME',
453  67465: 'PLACENAME',
454  72424: 'PLACENAME',
455  75531: 'PLACENAME',
456  77918: 'PLACENAME',
457  78048: 'PLACENAME',
458  78352: 'PLACENAME',
459  78383: 'PLACENAME',
460  79078: 'PLACENAME',
461  84489: 'PLACENAME',
462  84518: 'PLACENAME',
463  84688: 'PLACENAME',
464  84695: 'PLACENAME',
465  88812: 'PLACENAME',
466  89205: 'PLACENAME',
467  89382: 'PLACENAME',
468  89734: 'PLACENAME',
469  93990: 'PLACENAME',
470  99407: 'PLACENAME',
471  99847: 'PLACENAME',
472  100073: 'PLACENAME',
473  101013: 'PLACENAME',
474  104020: 'PLACENAME',
475  106118: 'PLACENAME',
476  106499: 'PLACENAME'},
477 'City': {2869: 'BROOKLYN',
478  23571: 'NEW YORK',
479  41625: 'JAMAICA',
480  44331: 'JAMAICA',
481  46913: 'BROOKLYN',
482  47459: 'NEW YORK',
483  48465: 'JAMAICA',
484  51837: 'NEW YORK',
485  51848: 'NEW YORK',
486  54089: 'NEW YORK',
487  54343: 'NEW YORK',
488  55140: 'CORONA',
489  57789: 'EAST ELMHURST',
490  63119: 'JAMAICA',
491  66242: 'EAST ELMHURST',
492  66758: 'NEW YORK',
493  66786: 'NEW YORK',
494  66809: 'JAMAICA',
495  67465: 'FLUSHING',
496  72424: 'BROOKLYN',
497  75531: 'NEW YORK',
498  77918: 'NEW YORK',
499  78048: 'EAST ELMHURST',
500  78352: 'BROOKLYN',
501  78383: 'CORONA',
502  79078: 'NEW YORK',
503  84489: 'BROOKLYN',
504  84518: 'BROOKLYN',
505  84688: 'BROOKLYN',
506  84695: 'BROOKLYN',
507  88812: 'JAMAICA',
508  89205: 'NEW YORK',
509  89382: 'BROOKLYN',
510  89734: 'NEW YORK',
511  93990: 'NEW YORK',
512  99407: 'JAMAICA',
513  99847: 'NEW YORK',
514  100073: 'NEW YORK',
515  101013: 'NEW YORK',
516  104020: 'JAMAICA',
517  106118: 'NEW YORK',
518  106499: 'EAST ELMHURST'},
519 'Landmark': {2869: 'BARCLAYS CENTER',
520  23571: 'CENTRAL PARK',
521  41625: 'J F K AIRPORT',
522  44331: 'J F K AIRPORT',
523  46913: 'BARTEL PRITCHARD SQUARE',
524  47459: 'CITY COLLEGE',
525  48465: 'PS 37',
526  51837: 'JACKIE ROBINSON PARK',
527  51848: 'JACKIE ROBINSON PARK',
528  54089: 'CENTRAL PARK',
529  54343: 'UNION SQUARE PARK',
530  55140: 'WORLDS FAIR MARINA',
531  57789: 'LA GUARDIA AIRPORT',
532  63119: 'J F K AIRPORT',
533  66242: 'LA GUARDIA AIRPORT',
534  66758: 'BRYANT PARK',
535  66786: 'BETH ISRAEL MED CENTER',
536  66809: 'J F K AIRPORT',
537  67465: 'QUEENS COLLEGE',
538  72424: 'BARCLAYS CENTER',
539  75531: 'CENTRAL PARK',
540  77918: 'CENTRAL PARK',
541  78048: 'LA GUARDIA AIRPORT',
542  78352: 'BARCLAYS CENTER',
543  78383: 'WORLDS FAIR MARINA',
544  79078: 'WASHINGTON SQUARE PARK',
545  84489: 'PROSPECT PARK',
546  84518: 'PROSPECT PARK',
547  84688: 'PROSPECT PARK',
548  84695: 'PROSPECT PARK',
549  88812: 'J F K AIRPORT',
550  89205: 'CENTRAL PARK',
551  89382: 'GRAND ARMY PLAZA',
552  89734: 'BRYANT PARK',
553  93990: 'BETH ISRAEL MED CENTER',
554  99407: 'J F K AIRPORT',
555  99847: 'PORT AUTH 42 STREET',
556  100073: 'MUSEUM NATURAL HIST',
557  101013: 'GRAND CENTRAL TERM',
558  104020: 'JFK',
559  106118: 'CENTRAL PARK',
560  106499: 'LA GUARDIA AIRPORT'},
561 'Status': {2869: 'Closed',
562  23571: 'Closed',
563  41625: 'Closed',
564  44331: 'Closed',
565  46913: 'Closed',
566  47459: 'Closed',
567  48465: 'Closed',
568  51837: 'Closed',
569  51848: 'Closed',
570  54089: 'Closed',
571  54343: 'Closed',
572  55140: 'Closed',
573  57789: 'Closed',
574  63119: 'Closed',
575  66242: 'Closed',
576  66758: 'Closed',
577  66786: 'Closed',
578  66809: 'Closed',
579  67465: 'Closed',
580  72424: 'Closed',
581  75531: 'Closed',
582  77918: 'Closed',
583  78048: 'Closed',
584  78352: 'Closed',
585  78383: 'Closed',
586  79078: 'Closed',
587  84489: 'Closed',
588  84518: 'Closed',
589  84688: 'Closed',
590  84695: 'Closed',
591  88812: 'Closed',
592  89205: 'Closed',
593  89382: 'Closed',
594  89734: 'Closed',
595  93990: 'Closed',
596  99407: 'Closed',
597  99847: 'Closed',
598  100073: 'Closed',
599  101013: 'Closed',
600  104020: 'Closed',
601  106118: 'Closed',
602  106499: 'Closed'},
603 'Borough': {2869: 'BROOKLYN',
604  23571: 'MANHATTAN',
605  41625: 'QUEENS',
606  44331: 'QUEENS',
607  46913: 'BROOKLYN',
608  47459: 'MANHATTAN',
609  48465: 'QUEENS',
610  51837: 'MANHATTAN',
611  51848: 'MANHATTAN',
612  54089: 'MANHATTAN',
613  54343: 'MANHATTAN',
614  55140: 'QUEENS',
615  57789: 'QUEENS',
616  63119: 'QUEENS',
617  66242: 'QUEENS',
618  66758: 'MANHATTAN',
619  66786: 'MANHATTAN',
620  66809: 'QUEENS',
621  67465: 'QUEENS',
622  72424: 'BROOKLYN',
623  75531: 'MANHATTAN',
624  77918: 'MANHATTAN',
625  78048: 'QUEENS',
626  78352: 'BROOKLYN',
627  78383: 'QUEENS',
628  79078: 'MANHATTAN',
629  84489: 'BROOKLYN',
630  84518: 'BROOKLYN',
631  84688: 'BROOKLYN',
632  84695: 'BROOKLYN',
633  88812: 'QUEENS',
634  89205: 'MANHATTAN',
635  89382: 'BROOKLYN',
636  89734: 'MANHATTAN',
637  93990: 'MANHATTAN',
638  99407: 'QUEENS',
639  99847: 'MANHATTAN',
640  100073: 'MANHATTAN',
641  101013: 'MANHATTAN',
642  104020: 'QUEENS',
643  106118: 'MANHATTAN',
644  106499: 'QUEENS'}}
645for c in ['Created Date', 'Closed Date']:
646    df[c] = pd.to_datetime(df[c])
647    #df[c+'_date'] = df[c].dt.date # to extract the date (for created + closed)
648    #df[c+'_time'] = df[c].dt.time # to extract the time (for created + closed)
649df['difference in time'] = (df['Closed Date'] - df['Created Date']).astype('timedelta64[h]')
650print(df.groupby('Complaint Type').agg({'difference in time':'mean'}))
651                            difference in time
652Complaint Type                                
653Dead Tree                            40.000000
654For Hire Vehicle Complaint           48.333333
655Illegal Parking                       0.500000
656Noise - Park                          1.916667
657Noise - Vehicle                       0.500000
658Overgrown Tree/Branches              15.000000
659Public Toilet                       125.500000
660Street Condition                    211.000000
661Taxi Complaint                      125.461538
662Traffic                               1.500000
663Vending                               3.666667
664

Source https://stackoverflow.com/questions/70447276

QUESTION

Is there any workaround for passing a function template as a template parameter?

Asked 2021-Dec-12 at 18:00

I'm trying to make a function template that takes a function template as a template argument and then returns the result of that function when invoked with the normal function parameters passed in. It would be used like this:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2

The point of the function is to allow template type deduction even when letting another function perform construction of an instance. I already do this manually in a lot of places in my code like this:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3

I got the idea of a helper function from this answer to a question I posted. He suggested to make one for a specific type but I want a function that can be used for any type.

Here's what I've come up with so far:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3template
4&lt;auto F, template&lt;typename U&gt; class T, typename... Args&gt;
5std::result_of_t&lt;decltype(F)&gt; 
6func(Args&amp;&amp;... args, std::enable_if_t&lt;std::is_invocable_v&lt;decltype(F), Args...&gt;&gt;* = nullptr)
7{
8    return F&lt;decltype(T{std::forward&lt;Args&gt;(args)...})&gt;(std::forward&lt;Args&gt;(args)...);
9}
10

But I can't get it to work.

Am I on the right track? Is what I'm trying to do even possible?

ANSWER

Answered 2021-Dec-12 at 18:00

You can't pass a templated function as a template argument unfortunately unless you specify the template arguments explicitly, e.g.:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3template
4&lt;auto F, template&lt;typename U&gt; class T, typename... Args&gt;
5std::result_of_t&lt;decltype(F)&gt; 
6func(Args&amp;&amp;... args, std::enable_if_t&lt;std::is_invocable_v&lt;decltype(F), Args...&gt;&gt;* = nullptr)
7{
8    return F&lt;decltype(T{std::forward&lt;Args&gt;(args)...})&gt;(std::forward&lt;Args&gt;(args)...);
9}
10template&lt;auto T&gt;
11auto func(auto&amp;&amp;... args) {
12    return T(std::forward&lt;decltype(args)&gt;(args)...);
13}
14
15struct Foo { Foo(int i) {} };
16
17int main() {
18    auto unique_foo = func&lt;std::make_unique&lt;Foo, int&gt;&gt;(1);
19}
20

You can however pass around templated function objects without problems, so the following would work:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3template
4&lt;auto F, template&lt;typename U&gt; class T, typename... Args&gt;
5std::result_of_t&lt;decltype(F)&gt; 
6func(Args&amp;&amp;... args, std::enable_if_t&lt;std::is_invocable_v&lt;decltype(F), Args...&gt;&gt;* = nullptr)
7{
8    return F&lt;decltype(T{std::forward&lt;Args&gt;(args)...})&gt;(std::forward&lt;Args&gt;(args)...);
9}
10template&lt;auto T&gt;
11auto func(auto&amp;&amp;... args) {
12    return T(std::forward&lt;decltype(args)&gt;(args)...);
13}
14
15struct Foo { Foo(int i) {} };
16
17int main() {
18    auto unique_foo = func&lt;std::make_unique&lt;Foo, int&gt;&gt;(1);
19}
20template&lt;class T&gt;
21struct unique {
22    auto operator()(auto&amp;&amp;... args) {
23        return std::make_unique&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
24    }
25};
26
27template&lt;class T&gt;
28struct shared {
29    auto operator()(auto&amp;&amp;... args) {
30        return std::make_shared&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
31    }
32};
33
34template&lt;template&lt;class&gt; class F, class T, class... Args&gt;
35  requires std::is_invocable_v&lt;F&lt;T&gt;, Args...&gt;
36auto func(Args&amp;&amp;... args) {
37    return F&lt;T&gt;{}(std::forward&lt;Args&gt;(args)...);
38}
39
40struct Foo { Foo(int i) {} };
41
42int main(){
43    auto foo_unique = func&lt;unique, Foo&gt;(1);
44    auto foo_shared = func&lt;shared, Foo&gt;(2);
45}
46

godbolt example

If you also need to deduce the template parameters of your class by the parameters passed to std::make_unique (like in your linked example), you can add an overload for func that deals with templated types:

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3template
4&lt;auto F, template&lt;typename U&gt; class T, typename... Args&gt;
5std::result_of_t&lt;decltype(F)&gt; 
6func(Args&amp;&amp;... args, std::enable_if_t&lt;std::is_invocable_v&lt;decltype(F), Args...&gt;&gt;* = nullptr)
7{
8    return F&lt;decltype(T{std::forward&lt;Args&gt;(args)...})&gt;(std::forward&lt;Args&gt;(args)...);
9}
10template&lt;auto T&gt;
11auto func(auto&amp;&amp;... args) {
12    return T(std::forward&lt;decltype(args)&gt;(args)...);
13}
14
15struct Foo { Foo(int i) {} };
16
17int main() {
18    auto unique_foo = func&lt;std::make_unique&lt;Foo, int&gt;&gt;(1);
19}
20template&lt;class T&gt;
21struct unique {
22    auto operator()(auto&amp;&amp;... args) {
23        return std::make_unique&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
24    }
25};
26
27template&lt;class T&gt;
28struct shared {
29    auto operator()(auto&amp;&amp;... args) {
30        return std::make_shared&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
31    }
32};
33
34template&lt;template&lt;class&gt; class F, class T, class... Args&gt;
35  requires std::is_invocable_v&lt;F&lt;T&gt;, Args...&gt;
36auto func(Args&amp;&amp;... args) {
37    return F&lt;T&gt;{}(std::forward&lt;Args&gt;(args)...);
38}
39
40struct Foo { Foo(int i) {} };
41
42int main(){
43    auto foo_unique = func&lt;unique, Foo&gt;(1);
44    auto foo_shared = func&lt;shared, Foo&gt;(2);
45}
46template&lt;template&lt;class...&gt; class T, class... Args&gt;
47using deduced_type = decltype(T{std::declval&lt;Args&gt;()...});
48
49template&lt;template&lt;class&gt; class F, template&lt;class...&gt; class T, class... Args&gt;
50  requires std::is_invocable_v&lt;F&lt;deduced_type&lt;T,Args...&gt;&gt;, Args...&gt;
51auto func(Args&amp;&amp;... args) {
52    return F&lt;deduced_type&lt;T, Args...&gt;&gt;{}(std::forward&lt;Args&gt;(args)...);
53}
54

godbolt example

that deduces the template parameters to your type T based on the passed in parameters.

1auto fooPtr = func&lt;std::make_unique, Foo&gt;(...);
2auto fooPtr = std::make_unique&lt;decltype(Foo{...})&gt;(...);
3template
4&lt;auto F, template&lt;typename U&gt; class T, typename... Args&gt;
5std::result_of_t&lt;decltype(F)&gt; 
6func(Args&amp;&amp;... args, std::enable_if_t&lt;std::is_invocable_v&lt;decltype(F), Args...&gt;&gt;* = nullptr)
7{
8    return F&lt;decltype(T{std::forward&lt;Args&gt;(args)...})&gt;(std::forward&lt;Args&gt;(args)...);
9}
10template&lt;auto T&gt;
11auto func(auto&amp;&amp;... args) {
12    return T(std::forward&lt;decltype(args)&gt;(args)...);
13}
14
15struct Foo { Foo(int i) {} };
16
17int main() {
18    auto unique_foo = func&lt;std::make_unique&lt;Foo, int&gt;&gt;(1);
19}
20template&lt;class T&gt;
21struct unique {
22    auto operator()(auto&amp;&amp;... args) {
23        return std::make_unique&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
24    }
25};
26
27template&lt;class T&gt;
28struct shared {
29    auto operator()(auto&amp;&amp;... args) {
30        return std::make_shared&lt;T&gt;(std::forward&lt;decltype(args)&gt;(args)...);
31    }
32};
33
34template&lt;template&lt;class&gt; class F, class T, class... Args&gt;
35  requires std::is_invocable_v&lt;F&lt;T&gt;, Args...&gt;
36auto func(Args&amp;&amp;... args) {
37    return F&lt;T&gt;{}(std::forward&lt;Args&gt;(args)...);
38}
39
40struct Foo { Foo(int i) {} };
41
42int main(){
43    auto foo_unique = func&lt;unique, Foo&gt;(1);
44    auto foo_shared = func&lt;shared, Foo&gt;(2);
45}
46template&lt;template&lt;class...&gt; class T, class... Args&gt;
47using deduced_type = decltype(T{std::declval&lt;Args&gt;()...});
48
49template&lt;template&lt;class&gt; class F, template&lt;class...&gt; class T, class... Args&gt;
50  requires std::is_invocable_v&lt;F&lt;deduced_type&lt;T,Args...&gt;&gt;, Args...&gt;
51auto func(Args&amp;&amp;... args) {
52    return F&lt;deduced_type&lt;T, Args...&gt;&gt;{}(std::forward&lt;Args&gt;(args)...);
53}
54template&lt;class A, class B&gt;
55struct Foo { Foo(A,B) {} };
56
57struct Bar { Bar(int i) {} };
58
59
60int main(){
61    // automatically deduces the types for A, B in Foo based on arguments
62    auto foo_unique = func&lt;unique, Foo&gt;(1, 2);
63
64    // the normal overload of func handles non-templated classes:
65    auto bar_unique = func&lt;unique, Bar&gt;(1);
66}
67

Source https://stackoverflow.com/questions/70324055

QUESTION

Thread safety of std::cout insertion operator

Asked 2021-Dec-03 at 17:02

I've always thought that using std::cout << something was thread safe.

For this little example

1#include &lt;iostream&gt;
2#include &lt;thread&gt;
3
4void f()
5{
6   std::cout &lt;&lt; &quot;Hello from f\n&quot;;
7}
8
9void g()
10{
11   std::cout &lt;&lt; &quot;Hello from g\n&quot;;
12}
13
14int main()
15{
16   std::thread t1(f);
17   std::thread t2(g);
18   t1.join();
19   t2.join();
20}
21

my expectation was that the order of the two outputs would be undefined (and indeed that is what I observe in practice), but that the calls to operator<< are thread safe.

However, ThreadSanitizer, DRD and Helgrind all seem to give various errors regarding access to std::__1::ios_base::width(long) and std::__1::basic_ios<char, std::__1::char_traits >::fill()

On Compiler Explorer I don't see any errors.

On FreeBSD 13, ThreadSanitizer gives me 3 warnings, the two listed above plus the malloc/memcpy to the underlying i/o buffer.

Again in FreeBSD 13, DRD gives 4 errors, width() and fill() times two for the two threads.

Finally FreeBSD 13 Helgrind gives one known false positive related to TLS in thread creation, fill()and width() twice.

On Fedora 34

  • No errors with g++ 11.2.1 and ThreadSanitizer
  • DRD complains about malloc/memcpy in fwrite with g++ compiled exe
  • Helgrind also complains about fwrite and also for the construction of cout, again with the g++ compiled exe
  • clang++ 12 ThreadSanitizer complains about fill() and width()
  • DRD with the clang++ compiler exe complains about fill(), width(), fwrite and one other in start_thread
  • Helgrind with the clang++ exe complains about some TLS, fill(), width(), fwrite

macOS XCode clang++ ThreadSanitizer generates warnings as well (which will be libc++).

Looking at the libc++ and libstdc++ code I don't see anything at all that protects width(). So I don't understand why there are no complaints on compiler explorer.

I tried running with TSAN_OPTIONS=print_suppressions=1 and there was no more output (g++ Fedora ThreadSanitizer)

There does seem to be some consensus over the width() and fill() calls.

Looking more closely at the libstdc++ source I see that there is (with some trimming and comments):

1#include &lt;iostream&gt;
2#include &lt;thread&gt;
3
4void f()
5{
6   std::cout &lt;&lt; &quot;Hello from f\n&quot;;
7}
8
9void g()
10{
11   std::cout &lt;&lt; &quot;Hello from g\n&quot;;
12}
13
14int main()
15{
16   std::thread t1(f);
17   std::thread t2(g);
18   t1.join();
19   t2.join();
20}
21// ostream_insert.h
22// __n is the length of the string pointed to by __s
23  template&lt;typename _CharT, typename _Traits&gt;
24    basic_ostream&lt;_CharT, _Traits&gt;&amp;
25    __ostream_insert(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out,
26             const _CharT* __s, streamsize __n)
27{
28    typedef basic_ostream&lt;_CharT, _Traits&gt;       __ostream_type;
29    typedef typename __ostream_type::ios_base    __ios_base;
30
31    typename __ostream_type::sentry __cerb(__out);
32    if (__cerb)
33    {
34        __try
35        {
36            const streamsize __w = __out.width();
37            if (__w &gt; __n)
38            {
39                // snipped
40                // handle padding
41            }
42            else
43              __ostream_write(__out, __s, __n);
44          // why no hazard here?
45          __out.width(0);
46      }
47
48

__out is the stream object, global cout in this case. I don't see anything like locks or atomics.

Any suggestions as to how ThreadSanitizer/g++ is getting a "clean" output?

There is this somewhat cryptic comment

1#include &lt;iostream&gt;
2#include &lt;thread&gt;
3
4void f()
5{
6   std::cout &lt;&lt; &quot;Hello from f\n&quot;;
7}
8
9void g()
10{
11   std::cout &lt;&lt; &quot;Hello from g\n&quot;;
12}
13
14int main()
15{
16   std::thread t1(f);
17   std::thread t2(g);
18   t1.join();
19   t2.join();
20}
21// ostream_insert.h
22// __n is the length of the string pointed to by __s
23  template&lt;typename _CharT, typename _Traits&gt;
24    basic_ostream&lt;_CharT, _Traits&gt;&amp;
25    __ostream_insert(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out,
26             const _CharT* __s, streamsize __n)
27{
28    typedef basic_ostream&lt;_CharT, _Traits&gt;       __ostream_type;
29    typedef typename __ostream_type::ios_base    __ios_base;
30
31    typename __ostream_type::sentry __cerb(__out);
32    if (__cerb)
33    {
34        __try
35        {
36            const streamsize __w = __out.width();
37            if (__w &gt; __n)
38            {
39                // snipped
40                // handle padding
41            }
42            else
43              __ostream_write(__out, __s, __n);
44          // why no hazard here?
45          __out.width(0);
46      }
47
48
49  template&lt;typename _CharT, typename _Traits&gt;
50    basic_ostream&lt;_CharT, _Traits&gt;::sentry::
51    sentry(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os)
52    : _M_ok(false), _M_os(__os)
53    {
54      // XXX MT
55      if (__os.tie() &amp;&amp; __os.good())
56    __os.tie()-&gt;flush();
57

The libc++ code looks similar. In iostream

1#include &lt;iostream&gt;
2#include &lt;thread&gt;
3
4void f()
5{
6   std::cout &lt;&lt; &quot;Hello from f\n&quot;;
7}
8
9void g()
10{
11   std::cout &lt;&lt; &quot;Hello from g\n&quot;;
12}
13
14int main()
15{
16   std::thread t1(f);
17   std::thread t2(g);
18   t1.join();
19   t2.join();
20}
21// ostream_insert.h
22// __n is the length of the string pointed to by __s
23  template&lt;typename _CharT, typename _Traits&gt;
24    basic_ostream&lt;_CharT, _Traits&gt;&amp;
25    __ostream_insert(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out,
26             const _CharT* __s, streamsize __n)
27{
28    typedef basic_ostream&lt;_CharT, _Traits&gt;       __ostream_type;
29    typedef typename __ostream_type::ios_base    __ios_base;
30
31    typename __ostream_type::sentry __cerb(__out);
32    if (__cerb)
33    {
34        __try
35        {
36            const streamsize __w = __out.width();
37            if (__w &gt; __n)
38            {
39                // snipped
40                // handle padding
41            }
42            else
43              __ostream_write(__out, __s, __n);
44          // why no hazard here?
45          __out.width(0);
46      }
47
48
49  template&lt;typename _CharT, typename _Traits&gt;
50    basic_ostream&lt;_CharT, _Traits&gt;::sentry::
51    sentry(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os)
52    : _M_ok(false), _M_os(__os)
53    {
54      // XXX MT
55      if (__os.tie() &amp;&amp; __os.good())
56    __os.tie()-&gt;flush();
57template&lt;class _CharT, class _Traits&gt;
58basic_ostream&lt;_CharT, _Traits&gt;&amp;
59__put_character_sequence(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os,
60                          const _CharT* __str, size_t __len)
61{
62#ifndef _LIBCPP_NO_EXCEPTIONS
63    try
64    {
65#endif // _LIBCPP_NO_EXCEPTIONS
66        typename basic_ostream&lt;_CharT, _Traits&gt;::sentry __s(__os);
67        if (__s)
68        {
69            typedef ostreambuf_iterator&lt;_CharT, _Traits&gt; _Ip;
70            if (__pad_and_output(_Ip(__os),
71                                 __str,
72                                 (__os.flags() &amp; ios_base::adjustfield) == ios_base::left ?
73                                     __str + __len :
74                                     __str,
75                                 __str + __len,
76                                 __os,
77                                 __os.fill()).failed())
78                __os.setstate(ios_base::badbit | ios_base::failbit);
79

and in locale

1#include &lt;iostream&gt;
2#include &lt;thread&gt;
3
4void f()
5{
6   std::cout &lt;&lt; &quot;Hello from f\n&quot;;
7}
8
9void g()
10{
11   std::cout &lt;&lt; &quot;Hello from g\n&quot;;
12}
13
14int main()
15{
16   std::thread t1(f);
17   std::thread t2(g);
18   t1.join();
19   t2.join();
20}
21// ostream_insert.h
22// __n is the length of the string pointed to by __s
23  template&lt;typename _CharT, typename _Traits&gt;
24    basic_ostream&lt;_CharT, _Traits&gt;&amp;
25    __ostream_insert(basic_ostream&lt;_CharT, _Traits&gt;&amp; __out,
26             const _CharT* __s, streamsize __n)
27{
28    typedef basic_ostream&lt;_CharT, _Traits&gt;       __ostream_type;
29    typedef typename __ostream_type::ios_base    __ios_base;
30
31    typename __ostream_type::sentry __cerb(__out);
32    if (__cerb)
33    {
34        __try
35        {
36            const streamsize __w = __out.width();
37            if (__w &gt; __n)
38            {
39                // snipped
40                // handle padding
41            }
42            else
43              __ostream_write(__out, __s, __n);
44          // why no hazard here?
45          __out.width(0);
46      }
47
48
49  template&lt;typename _CharT, typename _Traits&gt;
50    basic_ostream&lt;_CharT, _Traits&gt;::sentry::
51    sentry(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os)
52    : _M_ok(false), _M_os(__os)
53    {
54      // XXX MT
55      if (__os.tie() &amp;&amp; __os.good())
56    __os.tie()-&gt;flush();
57template&lt;class _CharT, class _Traits&gt;
58basic_ostream&lt;_CharT, _Traits&gt;&amp;
59__put_character_sequence(basic_ostream&lt;_CharT, _Traits&gt;&amp; __os,
60                          const _CharT* __str, size_t __len)
61{
62#ifndef _LIBCPP_NO_EXCEPTIONS
63    try
64    {
65#endif // _LIBCPP_NO_EXCEPTIONS
66        typename basic_ostream&lt;_CharT, _Traits&gt;::sentry __s(__os);
67        if (__s)
68        {
69            typedef ostreambuf_iterator&lt;_CharT, _Traits&gt; _Ip;
70            if (__pad_and_output(_Ip(__os),
71                                 __str,
72                                 (__os.flags() &amp; ios_base::adjustfield) == ios_base::left ?
73                                     __str + __len :
74                                     __str,
75                                 __str + __len,
76                                 __os,
77                                 __os.fill()).failed())
78                __os.setstate(ios_base::badbit | ios_base::failbit);
79
80template &lt;class _CharT, class _OutputIterator&gt;
81_LIBCPP_HIDDEN
82_OutputIterator
83__pad_and_output(_OutputIterator __s,
84                 const _CharT* __ob, const _CharT* __op, const _CharT* __oe,
85                 ios_base&amp; __iob, _CharT __fl)
86{
87    streamsize __sz = __oe - __ob;
88    streamsize __ns = __iob.width();
89    if (__ns &gt; __sz)
90        __ns -= __sz;
91    else
92        __ns = 0;
93    for (;__ob &lt; __op; ++__ob, ++__s)
94        *__s = *__ob;
95    for (; __ns; --__ns, ++__s)
96        *__s = __fl;
97    for (; __ob &lt; __oe; ++__ob, ++__s)
98        *__s = *__ob;
99    __iob.width(0);
100    return __s;
101}
102

Again I see no thread protection, but also this time the tools detect a hazard.

Are these real issues? For plain calls to operator<< the value of width doesn't change, and is always 0.

ANSWER

Answered 2021-Nov-28 at 10:28

libstdc++ does not produce the error while libc++ does.

iostream.objects.overview Concurrent access to a synchronized ([ios.members.static]) standard iostream object's formatted and unformatted input ([istream]) and output ([ostream]) functions or a standard C stream by multiple threads does not result in a data race ([intro.multithread]).

So this looks like a libc++ bug to me.

Source https://stackoverflow.com/questions/70141680

QUESTION

Why doesn't std::string have a constructor that directly takes std::string_view?

Asked 2021-Dec-02 at 08:14

To allow std::string construction from std::string_viewthere is a template constructor

1template&lt;class T&gt;
2explicit basic_string(const T&amp; t, const Allocator&amp; alloc = Allocator());
3

which is enabled only if const T& is convertible to std::basic_string_view<CharT, Traits> (link).

In the meantime there is a special deduction guide to deduce basic_string from basic_string_view (link). A comment to the guide says:

Guides (2-3) are needed because the std::basic_string constructors for std::basic_string_views are made templates to avoid causing ambiguities in existing code, and those templates do not support class template argument deduction.

So I'm curious, what is that ambiguity that requires to have that deduction guide and template constructor instead of simply a constructor that takes std::basic_string_view, e.g. something like

1template&lt;class T&gt;
2explicit basic_string(const T&amp; t, const Allocator&amp; alloc = Allocator());
3explicit basic_string(basic_string_view&lt;CharT, Traits&gt; sv, const Allocator&amp; alloc = Allocator());
4

Note that I'm not asking why the constructor is marked explicit.

ANSWER

Answered 2021-Dec-02 at 08:14

The ambiguity is that std::string and std::string_view are both constructible from const char *. That makes things like

1template&lt;class T&gt;
2explicit basic_string(const T&amp; t, const Allocator&amp; alloc = Allocator());
3explicit basic_string(basic_string_view&lt;CharT, Traits&gt; sv, const Allocator&amp; alloc = Allocator());
4std::string{}.assign(&quot;ABCDE&quot;, 0, 1)
5

ambiguous if the first parameter can be either a string or a string_view.

There are several defect reports trying to sort this out, starting here.

https://cplusplus.github.io/LWG/lwg-defects.html#2758

The first thing was to make members taking string_view into templates, which lowers their priority in overload resolution. Apparently, that was a bit too effective, so other adjustments were added later.

Source https://stackoverflow.com/questions/70113292

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Construction

Tutorials and Learning Resources are not available at this moment for Construction

Share this Page

share link

Get latest updates on Construction