I faced the same problem, in my case it was because I had duplicate column names after the join.
I see you have report_date and marketplaceid in both dataframes. For each duplicated pair, you need to either drop one or both, or rename one of them.
python - "AttributeError: 'DataFrame' object has no attribute 'dtype'" using pandas to_datetime - Stack Overflow
AttributeError: 'DataFrame' object has no attribute 'dtype'
AttributeError: 'DataFrame' object has no attribute 'dtype'
BUG: AttributeError: type object 'object' has no attribute 'dtype' with numpy 1.20.x and pandas versions 1.0.4 and earlier
This works for me on the current version of pandas:
pd.to_datetime(df)
0 2015-02-04
1 2016-03-05
dtype: datetime64[ns]
Pandas to_datetime has special support to parse a datetime column from a supplied DataFrame input iff it contains specifically "year", "month" and "day" columns (order doesn't matter, and case sensitivity doesn't either).
It's likely you're working with a much older version of pandas in which case I'd recommend an upgrade!
However...
If upgrading isn't an option, you can always join the columns and call to_datetime on the Series.
Try joining the columns and then applying pd.to_datetime.
pd.to_datetime(df[['year', 'month', 'day']].astype(str).apply('-'.join, 1))
0 2015-02-04
1 2016-03-05
dtype: datetime64[ns]
DataFrame.dtypes is an attribute to list data types, for series it's a dtype.
reference: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dtypes.html
"sklearn.datasets" is a scikit package, where it contains a method load_iris().
load_iris(), by default return an object which holds data, target and other members in it. In order to get actual values you have to read the data and target content itself.
Whereas 'iris.csv', holds feature and target together.
FYI: If you set return_X_y as True in load_iris(), then you will directly get features and target.
from sklearn import datasets
data,target = datasets.load_iris(return_X_y=True)
The Iris Dataset from Sklearn is in Sklearn's Bunch format:
print(type(iris))
print(iris.keys())
output:
<class 'sklearn.utils.Bunch'>
dict_keys(['data', 'target', 'target_names', 'DESCR', 'feature_names', 'filename'])
So, that's why you can access it as:
x=iris.data
y=iris.target
But when you read the CSV file as DataFrame as mentioned by you:
iris = pd.read_csv('iris.csv',header=None).iloc[:,2:4]
iris.head()
output is:
2 3
0 petal_length petal_width
1 1.4 0.2
2 1.4 0.2
3 1.3 0.2
4 1.5 0.2
Here the column names are '1' and '2'.
First of all you should read the CSV file as:
df = pd.read_csv('iris.csv')
you should not include header=None as your csv file includes the column names i.e. the headers.
So, now what you can do is something like this:
X = df.iloc[:, [2, 3]] # Will give you columns 2 and 3 i.e 'petal_length' and 'petal_width'
y = df.iloc[:, 4] # Label column i.e 'species'
or if you want to use the column names then:
X = df[['petal_length', 'petal_width']]
y = df.iloc['species']
Also, if you want to convert labels from string to numerical format use sklearn LabelEncoder
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
y = le.fit_transform(y)
why is this code throwing this error:
'tuple' object has no attribute 'dtype'
Code:
hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
h, s, v = cv2.split(hsv_img)
clahe = cv2.createCLAHE(clipLimit=2.6, tileGridSize=(3,3))
clahe_v = clahe.apply(v)
dwts = pywt.dwt(s, 'bior1.3')
smin = np.amin(dwts)
smax = np.amax(dwts)
print("smin:", smin, "smax:", smax)
sleep(2)
smin_new = 2.589 * smin
smax_new = 0.9 * smax
print("smin_new:", smin_new, "smax_new:", smax_new)
sleep(2)
magic_s = skimage.exposure.rescale_intensity(dwts, in_range=(smin,smax), out_range=(smin_new,smax_new)).astype(np.uint8) # this is the part throwing the error