Home > other >  Data analysis methods to consult
Data analysis methods to consult

Time:09-29

Now there are millions of records, can be divided into hundreds of thousands of sets of data, according to the ID each ID exist under different combination, consult everybody how to sort out these combinations?
Such as
ID product prices
111 A 10
111 B
111 C 9
222 A 10
222 B

Contains A B C I want how many? Include how many AB?
As long as give a hint, I slowly thinking!

CodePudding user response:

One of two ways.
1, SQL the direct analysis with decode (), is similar to the following list
Product id number, number of product B, product C

ORACLE is decode, MYSQL as the when case

2, python

Iterate through all the data, set up the dictionary list of the product value is set, that's good operation, and can be set directly,
[{' id ':' 111 ', 'product' : (' A ', 'B', 'C')},
{' id ':' 222 ', 'product' : (' A ', 'B')}]

Finally, traversing the dictionary list to get the target list

CodePudding user response:

reference 1/f, old coconut response:
two ways!
1, SQL the direct analysis with decode (), is similar to the following list
Product id number, number of product B, product C

ORACLE is decode, MYSQL as the when case

2, python

Iterate through all the data, set up the dictionary list of the product value is set, that's good operation, and can be set directly,
[{' id ':' 111 ', 'product' : (' A ', 'B', 'C')},
{' id ':' 222 ', 'product' : (' A ', 'B')}]

Then traverse the dictionary to get the target list
thank you, excuse me may I still have no clear, I don't know what combination is now, may be a ABC, abcd etc. First of all want to know how many kinds of combination, ABC bac position but as a combination of different now need to know how many ID different combinations

CodePudding user response:

Then use the second method, I've written a similar application, calculation of combination, record data in a dictionary, combination with collection, it would ensure that ABC bac as a combination

CodePudding user response:

reference old coconut reply: 3/f
then use the second method, I've written a similar application, calculation of combination, record data in a dictionary, combined with the collection, this can guarantee the ABC bac is regarded as a composite
thank you very much to try first
  • Related