The big difference I've noticed is assignment.
import random
import pandas as pd
s = "SummerCrime|WinterCrime".split("|")
j = {x: [random.choice(["ASB", "Violence", "Theft", "Public Order", "Drugs"]) for j in range(300)] for x in s}
df = pd.DataFrame(j)
df.FallCrime = [random.choice(["ASB", "Violence", "Theft", "Public Order", "Drugs"]) for j in range(300)]
Gives: UserWarning: Pandas doesn't allow columns to be created via a new attribute name
However, there are also docs associated with this, which has the following warnings which may be related to your problem:
- You can use this access only if the index element is a valid Python identifier, e.g.
s.1
is not allowed. See here for an explanation of valid identifiers.
- The attribute will not be available if it conflicts with an existing method name, e.g.
s.min
is not allowed, but s['min']
is possible.
- Similarly, the attribute will not be available if it conflicts with any of the following list:
index
, major_axis
, minor_axis
, items
.
- In any of these cases, standard indexing will still work, e.g.
s['1']
, s['min']
, and s['index']
will access the corresponding element or column.
They go on to say:
You can use attribute access to modify an existing element of a Series or column of a DataFrame, but be careful; if you try to use attribute access to create a new column, it creates a new attribute rather than a new column. In 0.21.0 and later, this will raise a UserWarning
So it's possible you did this without realizing.