'datetime.datetime' has no attribute 'datetime' in pythonAttributeError: 'DataFrame' object has no attribute 'allah1__27'Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?Should I use the datetime or timestamp data type in MySQL?How to get the current time in PythonConverting string into datetimeDoes Python have a string 'contains' substring method?
Using font to highlight a god's speech in dialogue
Where should I draw the line on follow up questions from previous employer
How to differentiate between two people with the same name in a story?
Does the Freedom of Movement spell prevent petrification by the Flesh to Stone spell?
Why haven't the British protested Brexit as ardently as the Hong Kong protesters?
A word for the urge to do the opposite
What is the practical impact of using System.Random which is not cryptographically random?
Deck of Many Things. What happens if you don't declare any number of cards and just start drawing?
Does the telecom provider need physical access to the SIM card to clone it?
How can I improve my formal definitions?
New coworker has strange workplace requirements - how should I deal with them?
What's the origin of the concept of alternate dimensions/realities?
How did the Altair 8800 front panel load the program counter?
How to draw a true pie chart?
A vector is defined to have a magnitude and *a* direction, but the zero vector has no *single* direction. So, how is the zero vector a vector?
Is the net torque changed when a partner on a seesaw stands or hangs from her end instead of sitting?
How does the search space affect the speed of an ILP solver?
How to run a command 1 out of N times in Bash
Why does the U.S. military maintain their own weather satellites?
Could a complex system of reaction wheels be used to propel a spacecraft?
Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code
Is it good practice to speed up and slow down where not written in a song?
Ideas behind the 8.Bd3 line in the 4.Ng5 Two Knights Defense
apt-file regex: find multiple packages at once using or
'datetime.datetime' has no attribute 'datetime' in python
AttributeError: 'DataFrame' object has no attribute 'allah1__27'Calling an external command in PythonWhat are metaclasses in Python?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?Should I use the datetime or timestamp data type in MySQL?How to get the current time in PythonConverting string into datetimeDoes Python have a string 'contains' substring method?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
hi i have long code maybe if you wanna check it out tell me, so im trying to solve this and I'm pretty sure the code is right but it keeps getting me the same error, i try everything to solve it but its the same i checked if the attribute missing but its there i don't know what i have done wrong
this is my code
import pandas as pd
import geopandas as gpd
import time
import pickle
import os
import numpy as np
import xgboost
import pytz
import arcgis
#
#plotting
#'''
from IPython.display import HTML, display
import datashader as ds
from datashader import transfer_functions as tf
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
#'''
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.ticker import NullFormatter
import matplotlib as mpl
mpl.rc('xtick', color='k')
mpl.rc('ytick', color='k')
%matplotlib inline
#'''
import datetime
from pandas import Series
from datetime import datetime, timedelta
import time
from datetime import datetime, date, time, timedelta
predTimest = pd.date_range('01/06/2017', periods=7*24, freq='H',tz='US/Mountain')
predTimest
n [28]:
predTimest
Out[28]:
DatetimeIndex(['2017-01-06 00:00:00-07:00', '2017-01-06 01:00:00-07:00',
'2017-01-06 02:00:00-07:00', '2017-01-06 03:00:00-07:00',
'2017-01-06 04:00:00-07:00', '2017-01-06 05:00:00-07:00',
'2017-01-06 06:00:00-07:00', '2017-01-06 07:00:00-07:00',
'2017-01-06 08:00:00-07:00', '2017-01-06 09:00:00-07:00',
...
'2017-01-12 14:00:00-07:00', '2017-01-12 15:00:00-07:00',
'2017-01-12 16:00:00-07:00', '2017-01-12 17:00:00-07:00',
'2017-01-12 18:00:00-07:00', '2017-01-12 19:00:00-07:00',
'2017-01-12 20:00:00-07:00', '2017-01-12 21:00:00-07:00',
'2017-01-12 22:00:00-07:00', '2017-01-12 23:00:00-07:00'],
dtype='datetime64[ns, US/Mountain]', length=168, freq='H')
prediction_time = predTimest[15]
test_df = shapefile.copy()
test_df['timestamp'] = prediction_time
test_df['allah1__27'] = shapefile.allah1__27.astype('int64')
test_df['hour'] = prediction_time.hour
test_df['weekday'] = prediction_time.weekday()
test_df['month'] = prediction_time.month
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
and it give me this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-4714b1ff587e> in <module>
----> 1 test_df = add_join_key(test_df)
2 weath_df = add_join_key(weath_df.reset_index())
<ipython-input-63-1a4e6a6f2c07> in add_join_key(df)
1 def add_join_key(df):
----> 2 df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
3 df = df.set_index('join_key')
4 return df
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
python datetime arcgis arcpy
add a comment |
hi i have long code maybe if you wanna check it out tell me, so im trying to solve this and I'm pretty sure the code is right but it keeps getting me the same error, i try everything to solve it but its the same i checked if the attribute missing but its there i don't know what i have done wrong
this is my code
import pandas as pd
import geopandas as gpd
import time
import pickle
import os
import numpy as np
import xgboost
import pytz
import arcgis
#
#plotting
#'''
from IPython.display import HTML, display
import datashader as ds
from datashader import transfer_functions as tf
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
#'''
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.ticker import NullFormatter
import matplotlib as mpl
mpl.rc('xtick', color='k')
mpl.rc('ytick', color='k')
%matplotlib inline
#'''
import datetime
from pandas import Series
from datetime import datetime, timedelta
import time
from datetime import datetime, date, time, timedelta
predTimest = pd.date_range('01/06/2017', periods=7*24, freq='H',tz='US/Mountain')
predTimest
n [28]:
predTimest
Out[28]:
DatetimeIndex(['2017-01-06 00:00:00-07:00', '2017-01-06 01:00:00-07:00',
'2017-01-06 02:00:00-07:00', '2017-01-06 03:00:00-07:00',
'2017-01-06 04:00:00-07:00', '2017-01-06 05:00:00-07:00',
'2017-01-06 06:00:00-07:00', '2017-01-06 07:00:00-07:00',
'2017-01-06 08:00:00-07:00', '2017-01-06 09:00:00-07:00',
...
'2017-01-12 14:00:00-07:00', '2017-01-12 15:00:00-07:00',
'2017-01-12 16:00:00-07:00', '2017-01-12 17:00:00-07:00',
'2017-01-12 18:00:00-07:00', '2017-01-12 19:00:00-07:00',
'2017-01-12 20:00:00-07:00', '2017-01-12 21:00:00-07:00',
'2017-01-12 22:00:00-07:00', '2017-01-12 23:00:00-07:00'],
dtype='datetime64[ns, US/Mountain]', length=168, freq='H')
prediction_time = predTimest[15]
test_df = shapefile.copy()
test_df['timestamp'] = prediction_time
test_df['allah1__27'] = shapefile.allah1__27.astype('int64')
test_df['hour'] = prediction_time.hour
test_df['weekday'] = prediction_time.weekday()
test_df['month'] = prediction_time.month
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
and it give me this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-4714b1ff587e> in <module>
----> 1 test_df = add_join_key(test_df)
2 weath_df = add_join_key(weath_df.reset_index())
<ipython-input-63-1a4e6a6f2c07> in add_join_key(df)
1 def add_join_key(df):
----> 2 df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
3 df = df.set_index('join_key')
4 return df
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
python datetime arcgis arcpy
1
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57
add a comment |
hi i have long code maybe if you wanna check it out tell me, so im trying to solve this and I'm pretty sure the code is right but it keeps getting me the same error, i try everything to solve it but its the same i checked if the attribute missing but its there i don't know what i have done wrong
this is my code
import pandas as pd
import geopandas as gpd
import time
import pickle
import os
import numpy as np
import xgboost
import pytz
import arcgis
#
#plotting
#'''
from IPython.display import HTML, display
import datashader as ds
from datashader import transfer_functions as tf
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
#'''
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.ticker import NullFormatter
import matplotlib as mpl
mpl.rc('xtick', color='k')
mpl.rc('ytick', color='k')
%matplotlib inline
#'''
import datetime
from pandas import Series
from datetime import datetime, timedelta
import time
from datetime import datetime, date, time, timedelta
predTimest = pd.date_range('01/06/2017', periods=7*24, freq='H',tz='US/Mountain')
predTimest
n [28]:
predTimest
Out[28]:
DatetimeIndex(['2017-01-06 00:00:00-07:00', '2017-01-06 01:00:00-07:00',
'2017-01-06 02:00:00-07:00', '2017-01-06 03:00:00-07:00',
'2017-01-06 04:00:00-07:00', '2017-01-06 05:00:00-07:00',
'2017-01-06 06:00:00-07:00', '2017-01-06 07:00:00-07:00',
'2017-01-06 08:00:00-07:00', '2017-01-06 09:00:00-07:00',
...
'2017-01-12 14:00:00-07:00', '2017-01-12 15:00:00-07:00',
'2017-01-12 16:00:00-07:00', '2017-01-12 17:00:00-07:00',
'2017-01-12 18:00:00-07:00', '2017-01-12 19:00:00-07:00',
'2017-01-12 20:00:00-07:00', '2017-01-12 21:00:00-07:00',
'2017-01-12 22:00:00-07:00', '2017-01-12 23:00:00-07:00'],
dtype='datetime64[ns, US/Mountain]', length=168, freq='H')
prediction_time = predTimest[15]
test_df = shapefile.copy()
test_df['timestamp'] = prediction_time
test_df['allah1__27'] = shapefile.allah1__27.astype('int64')
test_df['hour'] = prediction_time.hour
test_df['weekday'] = prediction_time.weekday()
test_df['month'] = prediction_time.month
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
and it give me this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-4714b1ff587e> in <module>
----> 1 test_df = add_join_key(test_df)
2 weath_df = add_join_key(weath_df.reset_index())
<ipython-input-63-1a4e6a6f2c07> in add_join_key(df)
1 def add_join_key(df):
----> 2 df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
3 df = df.set_index('join_key')
4 return df
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
python datetime arcgis arcpy
hi i have long code maybe if you wanna check it out tell me, so im trying to solve this and I'm pretty sure the code is right but it keeps getting me the same error, i try everything to solve it but its the same i checked if the attribute missing but its there i don't know what i have done wrong
this is my code
import pandas as pd
import geopandas as gpd
import time
import pickle
import os
import numpy as np
import xgboost
import pytz
import arcgis
#
#plotting
#'''
from IPython.display import HTML, display
import datashader as ds
from datashader import transfer_functions as tf
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
#'''
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.ticker import NullFormatter
import matplotlib as mpl
mpl.rc('xtick', color='k')
mpl.rc('ytick', color='k')
%matplotlib inline
#'''
import datetime
from pandas import Series
from datetime import datetime, timedelta
import time
from datetime import datetime, date, time, timedelta
predTimest = pd.date_range('01/06/2017', periods=7*24, freq='H',tz='US/Mountain')
predTimest
n [28]:
predTimest
Out[28]:
DatetimeIndex(['2017-01-06 00:00:00-07:00', '2017-01-06 01:00:00-07:00',
'2017-01-06 02:00:00-07:00', '2017-01-06 03:00:00-07:00',
'2017-01-06 04:00:00-07:00', '2017-01-06 05:00:00-07:00',
'2017-01-06 06:00:00-07:00', '2017-01-06 07:00:00-07:00',
'2017-01-06 08:00:00-07:00', '2017-01-06 09:00:00-07:00',
...
'2017-01-12 14:00:00-07:00', '2017-01-12 15:00:00-07:00',
'2017-01-12 16:00:00-07:00', '2017-01-12 17:00:00-07:00',
'2017-01-12 18:00:00-07:00', '2017-01-12 19:00:00-07:00',
'2017-01-12 20:00:00-07:00', '2017-01-12 21:00:00-07:00',
'2017-01-12 22:00:00-07:00', '2017-01-12 23:00:00-07:00'],
dtype='datetime64[ns, US/Mountain]', length=168, freq='H')
prediction_time = predTimest[15]
test_df = shapefile.copy()
test_df['timestamp'] = prediction_time
test_df['allah1__27'] = shapefile.allah1__27.astype('int64')
test_df['hour'] = prediction_time.hour
test_df['weekday'] = prediction_time.weekday()
test_df['month'] = prediction_time.month
def add_join_key(df):
df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
df = df.set_index('join_key')
return df
weath_df = wdf.loc[prediction_time]
test_df = add_join_key(test_df)
weath_df = add_join_key(weath_df.reset_index())
and it give me this error
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-65-4714b1ff587e> in <module>
----> 1 test_df = add_join_key(test_df)
2 weath_df = add_join_key(weath_df.reset_index())
<ipython-input-63-1a4e6a6f2c07> in add_join_key(df)
1 def add_join_key(df):
----> 2 df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datetime.datetime.isoformat)
3 df = df.set_index('join_key')
4 return df
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'
python datetime arcgis arcpy
python datetime arcgis arcpy
edited Mar 28 at 23:34
desertnaut
24.7k9 gold badges55 silver badges87 bronze badges
24.7k9 gold badges55 silver badges87 bronze badges
asked Mar 27 at 23:53
Maram MubarakMaram Mubarak
181 silver badge7 bronze badges
181 silver badge7 bronze badges
1
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57
add a comment |
1
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57
1
1
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57
add a comment |
2 Answers
2
active
oldest
votes
You have imported datetime twice at the top of your script with the last import taking precedence:
import datetime
from datetime import datetime, timedelta
Therefore you should be calling:
datetime.isoformat
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing toadd_join_key
does not have that column present. It is probably linked to this dfweath_df
since thetest_df
has the column you are specifying.
– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
add a comment |
You should not import datetime
and also from datetime import datetime
. Best practice would be to just import datetime
and then if you want the deeper module call datetime.datetime
otherwise you are creating two things with the exact same name...obviously this would lead to confusion. If you really want to import both then rename one like
import datetime
from datetime import datetime as datet
Now you can refer to one as datetime
and the other as datet
instead of having both of them refer to the same name "datetime
"
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would bedatet.isoformat
. After renaming it you have to use the new name to access it
– Reedinationer
Mar 28 at 0:15
still the samedef add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388199%2fdatetime-datetime-has-no-attribute-datetime-in-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have imported datetime twice at the top of your script with the last import taking precedence:
import datetime
from datetime import datetime, timedelta
Therefore you should be calling:
datetime.isoformat
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing toadd_join_key
does not have that column present. It is probably linked to this dfweath_df
since thetest_df
has the column you are specifying.
– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
add a comment |
You have imported datetime twice at the top of your script with the last import taking precedence:
import datetime
from datetime import datetime, timedelta
Therefore you should be calling:
datetime.isoformat
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing toadd_join_key
does not have that column present. It is probably linked to this dfweath_df
since thetest_df
has the column you are specifying.
– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
add a comment |
You have imported datetime twice at the top of your script with the last import taking precedence:
import datetime
from datetime import datetime, timedelta
Therefore you should be calling:
datetime.isoformat
You have imported datetime twice at the top of your script with the last import taking precedence:
import datetime
from datetime import datetime, timedelta
Therefore you should be calling:
datetime.isoformat
answered Mar 27 at 23:56
cullziecullzie
1,6752 gold badges6 silver badges13 bronze badges
1,6752 gold badges6 silver badges13 bronze badges
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing toadd_join_key
does not have that column present. It is probably linked to this dfweath_df
since thetest_df
has the column you are specifying.
– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
add a comment |
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing toadd_join_key
does not have that column present. It is probably linked to this dfweath_df
since thetest_df
has the column you are specifying.
– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
i did that before i got this error AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:08
Then the DataFrame object you are passing to
add_join_key
does not have that column present. It is probably linked to this df weath_df
since the test_df
has the column you are specifying.– cullzie
Mar 28 at 0:13
Then the DataFrame object you are passing to
add_join_key
does not have that column present. It is probably linked to this df weath_df
since the test_df
has the column you are specifying.– cullzie
Mar 28 at 0:13
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
how can i fix it
– Maram Mubarak
Mar 28 at 0:21
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
Create another question. This is unrelated to what your problem was here
– cullzie
Mar 28 at 0:24
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
i did here's the link stackoverflow.com/questions/55388516/…
– Maram Mubarak
Mar 28 at 0:37
add a comment |
You should not import datetime
and also from datetime import datetime
. Best practice would be to just import datetime
and then if you want the deeper module call datetime.datetime
otherwise you are creating two things with the exact same name...obviously this would lead to confusion. If you really want to import both then rename one like
import datetime
from datetime import datetime as datet
Now you can refer to one as datetime
and the other as datet
instead of having both of them refer to the same name "datetime
"
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would bedatet.isoformat
. After renaming it you have to use the new name to access it
– Reedinationer
Mar 28 at 0:15
still the samedef add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
add a comment |
You should not import datetime
and also from datetime import datetime
. Best practice would be to just import datetime
and then if you want the deeper module call datetime.datetime
otherwise you are creating two things with the exact same name...obviously this would lead to confusion. If you really want to import both then rename one like
import datetime
from datetime import datetime as datet
Now you can refer to one as datetime
and the other as datet
instead of having both of them refer to the same name "datetime
"
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would bedatet.isoformat
. After renaming it you have to use the new name to access it
– Reedinationer
Mar 28 at 0:15
still the samedef add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
add a comment |
You should not import datetime
and also from datetime import datetime
. Best practice would be to just import datetime
and then if you want the deeper module call datetime.datetime
otherwise you are creating two things with the exact same name...obviously this would lead to confusion. If you really want to import both then rename one like
import datetime
from datetime import datetime as datet
Now you can refer to one as datetime
and the other as datet
instead of having both of them refer to the same name "datetime
"
You should not import datetime
and also from datetime import datetime
. Best practice would be to just import datetime
and then if you want the deeper module call datetime.datetime
otherwise you are creating two things with the exact same name...obviously this would lead to confusion. If you really want to import both then rename one like
import datetime
from datetime import datetime as datet
Now you can refer to one as datetime
and the other as datet
instead of having both of them refer to the same name "datetime
"
edited Mar 28 at 0:07
answered Mar 27 at 23:57
ReedinationerReedinationer
4,0801 gold badge4 silver badges27 bronze badges
4,0801 gold badge4 silver badges27 bronze badges
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would bedatet.isoformat
. After renaming it you have to use the new name to access it
– Reedinationer
Mar 28 at 0:15
still the samedef add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
add a comment |
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would bedatet.isoformat
. After renaming it you have to use the new name to access it
– Reedinationer
Mar 28 at 0:15
still the samedef add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did that already, but I don't know what are you meaning by that "exact same name"
– Maram Mubarak
Mar 28 at 0:05
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
@reedinarioner i did what you say i import datetime only and i get AttributeError: module 'datetime' has no attribute 'isoformat'
– Maram Mubarak
Mar 28 at 0:14
Right. If you've renamed it then it would be
datet.isoformat
. After renaming it you have to use the new name to access it– Reedinationer
Mar 28 at 0:15
Right. If you've renamed it then it would be
datet.isoformat
. After renaming it you have to use the new name to access it– Reedinationer
Mar 28 at 0:15
still the same
def add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
still the same
def add_join_key(df): df['join_key'] = df.allah1__27.map(int).map(str)+df.timestamp.map(datet.isoformat) df = df.set_index('join_key') return df
AttributeError: 'DataFrame' object has no attribute 'allah1__27'
– Maram Mubarak
Mar 28 at 0:24
1
1
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
What do you mean “still the same”? That’s clearly a different error message...
– Reedinationer
Mar 28 at 1:02
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55388199%2fdatetime-datetime-has-no-attribute-datetime-in-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
remove one of datetime
– Ayoub Benayache
Mar 27 at 23:57