Home>
In the following data frame
import pandas as pd
item = [frozenset (['a']), frozenset (['b']), frozenset (['c']), frozenset (['d']), frozenset (['a', 'b'] ), frozenset (['a', 'b', 'c'])]
df = pd.DataFrame ({'N': item})
N | |
---|---|
0 | (a) |
1 | (b) |
2 | (c) |
3 | (d) |
4 | (a, b) |
5 | (a, b, c) |
I have extracted one item as follows. Is there any other good way?
items = set ()
for index, row in df.iterrows ():
for i in row ['N']:
items.add (i)
df_items = pd.DataFrame (columns = ['N'])
for item in items:
df_items = df_items.append (df [df ['N'] == frozenset (item)])
df_items = df_items.reset_index (drop = True)
df_items
N | |
---|---|
0 | (a) |
1 | (b) |
2 | (c) |
3 | (d) |
-
Answer # 1
Related articles
- python - i want to extract only the dataframe index of 500ms
- python - i want to sort and extract the top n columns for each "dataframe" index
- python - how to extract only the date from datetime64 [ns] type
- python - i want to create a new dataframe by repeating the work of extracting the average value of the dataframe
- i want to extract one character string of text that exists in multiple files with python
- python - pyrhon save colored dataframe color turns black
- i want to extract specific information from a python string
- linking data with python dataframe
- python 3x - i want to extract data from a python list 2
- python 3x - i want to extract data from a python3 tkinter list
- python - i want to move data from pandas dataframe to excel
- i want to extract csv duplicate keywords in python
- python - i want to collate and extract dates between two tables with sqlite
- python 3x - extract puns with web scraping
- python - i want to extract only the columns that satisfy the conditions with pytorch
- python that wants to extract only "october 31, 2020 (saturday)" from the character string "october 31, 2020 (satu
- i want to extract only those that have common items in the dataset [python]
- extract a line containing an arbitrary character string in a python regular expression text file and write it to an excel file
- python 3x - beautiful soup i want to extract a specific character string
- python - export time from postgres to pandas dataframe with django orm and output in utc
Related questions
- python : I want to delete lines other than numbers (characters, blank lines, etc.) in Excel
- python : ValueError: Input contains NaN, infinity or a value too large for dtype ('float32')
- python : Filter specific rows with year in a dataframe (pandas)?
- python : How to import image into SQLite
- python : How do I add new computed columns with conditions in Pandas?
- python : Output in order pandas, dataframe
- python : batch rename files using Pandas
- python : Very long loop run in jupyter-notebook
- python : How to remove data gaps in the set date
- python : Need help finding the index on the Series object s