Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to convert "frozenset({})" string to the data type frozenset?

$
0
0

I am trying to learn recommendation systems. I've imported associative rules to my sheet but antecedents and consequents values are formatted as strings I need to convert them to the data type frozenset in python.If a have a string like "frozenset({3048, 3046})" I need to convert it to (3048,3046)How can I do that?

Here is the sample code.

import pandas as pdfrozen_df =  [{"antecedents" : "frozenset({3048, 3046})","consequents" : "frozenset({10})"},              {"antecedents" : "frozenset({3504, 3507})","consequents" : "frozenset({3048, 85})"}]frozen_df = pd.DataFrame(frozen_df)frozen_df.dtypes

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>