I encountered this unexpected behavior using pandas that I don't quite know how to explain, and have not found any related questions here in SO.
When creating a dataframe from a dictionary of lists, as expected we get each element from the iterable into a new row in the columns specified by the given key:
pd.DataFrame({'a':[1,2,3]})
a
0 1
1 2
2 3
However, trying to do the same with a set, produced:
pd.DataFrame({'a':{1,2,3}})
a
0 {1, 2, 3}
1 {1, 2, 3}
2 {1, 2, 3}
So it seems that the set was replicated up to the amount of elements it actually contains, i.e 3.
I know it does not really make sense to use a set for this, since sets are by definition unordered collections. However I could not find any references or explanations behind this behaviour. Is this specified somewhere in the docs? Is there an obvious reason behind this that I'm missing?
pd.__version__
# '1.0.0'