Change column values conditionally and repeat several timesHow to change the order of DataFrame columns?How to drop rows of Pandas DataFrame whose value in a certain column is NaNChange data type of columns in PandasSelect rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column valueReshaping Pandas DataFrame with Repeated Column Indexpython if-else statement returning true only for if conditionDataFrame drop rows whose column has certain valuespandas DataFrame reshape by multiple column valuesCount occurences for each day in pandas dataframe

Is it normal practice to screen share with a client?

How to judge a Ph.D. applicant that arrives "out of thin air"

Can two figures have the same area, perimeter, and same number of segments have different shape?

How to deal with a player who makes bad characters and kills them?

What is a Waiting Word™?

How do we explain the E major chord in this progression?

What does コテッと mean?

A planet illuminated by a black hole?

Does academia have a lazy work culture?

Basic Questions on Wiener Filtering

"I you already know": is this proper English?

What is the meaning of "you has the wind of me"?

Keeping an "hot eyeball planet" wet

Send a single HTML email from Thunderbird, overriding the default "plain text" setting

Is it legal for private citizens to "impound" e-scooters?

Can the 2019 UA Artificer's Returning Weapon and Radiant Weapon infusions stack on the same weapon?

What is the effect and/or good reasons of changing a paper bill to a coin?

Should I have protein shakes the next day after workout, or only right after workout?

What self-defense weapons are legal in London?

Are there any examples of technologies have been lost over time?

Convert a string like 4h53m12s to a total number of seconds in JavaScript

Why are off grid solar setups only 12, 24, 48 VDC?

Drillers for petroleum strike gusher of blood

What do I do when a student working in my lab "ghosts" me?



Change column values conditionally and repeat several times


How to change the order of DataFrame columns?How to drop rows of Pandas DataFrame whose value in a certain column is NaNChange data type of columns in PandasSelect rows from a DataFrame based on values in a column in pandasDeleting DataFrame row in Pandas based on column valueReshaping Pandas DataFrame with Repeated Column Indexpython if-else statement returning true only for if conditionDataFrame drop rows whose column has certain valuespandas DataFrame reshape by multiple column valuesCount occurences for each day in pandas dataframe






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am trying to replace values in certain columns in a pandas dataframe. Because there are a number of changes to make, I’m approaching it with a for loop (though I am not wedded to this as the answer). I am only starting out with python, so huge apologies if this is obvious – I can’t find anything that seems to solve it.



Say I have a dataframe that is something like this:



import pandas as pd

weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])


Where the weather data is unknown, I want to use text from the notes to fill in the data. For example, if it says “rain” then I want the weather value to be “rainy”, assuming it was previously unknown.



I have tried this:



weather_text = ["rain", "sun"]
weather_label = ["rainy", "sunny"]

for i in range(len(weather_text)):
weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
weather['weather'].str.contains("unknown")] = weather_label[i]



This changes every value in the row that meets the condition to whatever is in weather_label. I can see why it’s doing that, but I’m not sure how to only change the relevant column. I’ve tried this:



for i in range(len(weather_text)):
weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
weather['weather']str.contains("unknown")]
weather['weather'] = weather_label[i]


But then the value is changed to the last value in the weather_label list, not the one at the same index position.



In my real data, there are a lot more combinations of patterns and values so I am not keen to run every combination individually.



Can anybody help?










share|improve this question




























    0















    I am trying to replace values in certain columns in a pandas dataframe. Because there are a number of changes to make, I’m approaching it with a for loop (though I am not wedded to this as the answer). I am only starting out with python, so huge apologies if this is obvious – I can’t find anything that seems to solve it.



    Say I have a dataframe that is something like this:



    import pandas as pd

    weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
    weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])


    Where the weather data is unknown, I want to use text from the notes to fill in the data. For example, if it says “rain” then I want the weather value to be “rainy”, assuming it was previously unknown.



    I have tried this:



    weather_text = ["rain", "sun"]
    weather_label = ["rainy", "sunny"]

    for i in range(len(weather_text)):
    weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
    weather['weather'].str.contains("unknown")] = weather_label[i]



    This changes every value in the row that meets the condition to whatever is in weather_label. I can see why it’s doing that, but I’m not sure how to only change the relevant column. I’ve tried this:



    for i in range(len(weather_text)):
    weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
    weather['weather']str.contains("unknown")]
    weather['weather'] = weather_label[i]


    But then the value is changed to the last value in the weather_label list, not the one at the same index position.



    In my real data, there are a lot more combinations of patterns and values so I am not keen to run every combination individually.



    Can anybody help?










    share|improve this question
























      0












      0








      0








      I am trying to replace values in certain columns in a pandas dataframe. Because there are a number of changes to make, I’m approaching it with a for loop (though I am not wedded to this as the answer). I am only starting out with python, so huge apologies if this is obvious – I can’t find anything that seems to solve it.



      Say I have a dataframe that is something like this:



      import pandas as pd

      weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
      weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])


      Where the weather data is unknown, I want to use text from the notes to fill in the data. For example, if it says “rain” then I want the weather value to be “rainy”, assuming it was previously unknown.



      I have tried this:



      weather_text = ["rain", "sun"]
      weather_label = ["rainy", "sunny"]

      for i in range(len(weather_text)):
      weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
      weather['weather'].str.contains("unknown")] = weather_label[i]



      This changes every value in the row that meets the condition to whatever is in weather_label. I can see why it’s doing that, but I’m not sure how to only change the relevant column. I’ve tried this:



      for i in range(len(weather_text)):
      weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
      weather['weather']str.contains("unknown")]
      weather['weather'] = weather_label[i]


      But then the value is changed to the last value in the weather_label list, not the one at the same index position.



      In my real data, there are a lot more combinations of patterns and values so I am not keen to run every combination individually.



      Can anybody help?










      share|improve this question














      I am trying to replace values in certain columns in a pandas dataframe. Because there are a number of changes to make, I’m approaching it with a for loop (though I am not wedded to this as the answer). I am only starting out with python, so huge apologies if this is obvious – I can’t find anything that seems to solve it.



      Say I have a dataframe that is something like this:



      import pandas as pd

      weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
      weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])


      Where the weather data is unknown, I want to use text from the notes to fill in the data. For example, if it says “rain” then I want the weather value to be “rainy”, assuming it was previously unknown.



      I have tried this:



      weather_text = ["rain", "sun"]
      weather_label = ["rainy", "sunny"]

      for i in range(len(weather_text)):
      weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
      weather['weather'].str.contains("unknown")] = weather_label[i]



      This changes every value in the row that meets the condition to whatever is in weather_label. I can see why it’s doing that, but I’m not sure how to only change the relevant column. I’ve tried this:



      for i in range(len(weather_text)):
      weather.loc[weather['weather_note'].str.contains(weather_text[i], na = False) &
      weather['weather']str.contains("unknown")]
      weather['weather'] = weather_label[i]


      But then the value is changed to the last value in the weather_label list, not the one at the same index position.



      In my real data, there are a lot more combinations of patterns and values so I am not keen to run every combination individually.



      Can anybody help?







      python pandas for-loop






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 26 at 17:32









      MeganMegan

      7973 silver badges20 bronze badges




      7973 silver badges20 bronze badges






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Here's how I'd do it. I used numpy in this code... hope that's okay. I just like numpy's vectorize method a lot. Pandas has an equivalent, but I don't tend to use it. The vectorize method (seen in last line of the code) is made for situations like this where you want to do *something* to a whole column, but it does it without requiring you to specify a loop in your code (it does the loop behind-the-scenes for you).



          import pandas as pd
          import numpy as np

          weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
          weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])

          weather_indicators = 'rain': 'rainy',
          'drizzle': 'rainy',
          'sun': 'sunny',
          'bright': 'sunny',
          # add each pattern to this dictionary


          def determine_weather(weather, weather_note):
          output = weather
          if weather == 'unknown':
          for indicator in weather_indicators:
          if indicator in weather_note:
          output = weather_indicators[indicator]
          return output


          weather['weather'] = np.vectorize(determine_weather)(weather['weather'], weather['weather_note'])


          I use a dictionary object named weather_indicators to store the patterns. You can add more patterns to it. If the amount of patterns is very large (like hundreds), then perhaps consider storing them in some other object like a database table or csv file or something and then reading that into the code. You'll obviously have to rework the above code at that point, since that's out of scope of your question.



          But basically I create a function that looks for a certain indicator word (e.g. "rain") and if the word is in the weather_note value then I set the weather column to be the specified value from the weather_indicator dictionary object. Then apply the function to the weather column of the data frame using numpy's vectorize function.






          share|improve this answer

























          • This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

            – Megan
            Mar 27 at 10:48


















          0














          Assign value from weather_note if value in weather is 'unknown'. Replace words like sun with sunny using df.replace.



          weather.loc[weather['weather'] == 'unknown', 'weather'] = weather['weather_note']
          weather['weather'].replace('sun', 'sunny', inplace = True)

          weather weather_note
          0 rainy rainy
          1 sunny sun
          2 rainy not sunny at all
          3 stormy a lot of rain





          share|improve this answer























          • Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

            – Megan
            Mar 27 at 10:51













          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363096%2fchange-column-values-conditionally-and-repeat-several-times%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









          1














          Here's how I'd do it. I used numpy in this code... hope that's okay. I just like numpy's vectorize method a lot. Pandas has an equivalent, but I don't tend to use it. The vectorize method (seen in last line of the code) is made for situations like this where you want to do *something* to a whole column, but it does it without requiring you to specify a loop in your code (it does the loop behind-the-scenes for you).



          import pandas as pd
          import numpy as np

          weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
          weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])

          weather_indicators = 'rain': 'rainy',
          'drizzle': 'rainy',
          'sun': 'sunny',
          'bright': 'sunny',
          # add each pattern to this dictionary


          def determine_weather(weather, weather_note):
          output = weather
          if weather == 'unknown':
          for indicator in weather_indicators:
          if indicator in weather_note:
          output = weather_indicators[indicator]
          return output


          weather['weather'] = np.vectorize(determine_weather)(weather['weather'], weather['weather_note'])


          I use a dictionary object named weather_indicators to store the patterns. You can add more patterns to it. If the amount of patterns is very large (like hundreds), then perhaps consider storing them in some other object like a database table or csv file or something and then reading that into the code. You'll obviously have to rework the above code at that point, since that's out of scope of your question.



          But basically I create a function that looks for a certain indicator word (e.g. "rain") and if the word is in the weather_note value then I set the weather column to be the specified value from the weather_indicator dictionary object. Then apply the function to the weather column of the data frame using numpy's vectorize function.






          share|improve this answer

























          • This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

            – Megan
            Mar 27 at 10:48















          1














          Here's how I'd do it. I used numpy in this code... hope that's okay. I just like numpy's vectorize method a lot. Pandas has an equivalent, but I don't tend to use it. The vectorize method (seen in last line of the code) is made for situations like this where you want to do *something* to a whole column, but it does it without requiring you to specify a loop in your code (it does the loop behind-the-scenes for you).



          import pandas as pd
          import numpy as np

          weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
          weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])

          weather_indicators = 'rain': 'rainy',
          'drizzle': 'rainy',
          'sun': 'sunny',
          'bright': 'sunny',
          # add each pattern to this dictionary


          def determine_weather(weather, weather_note):
          output = weather
          if weather == 'unknown':
          for indicator in weather_indicators:
          if indicator in weather_note:
          output = weather_indicators[indicator]
          return output


          weather['weather'] = np.vectorize(determine_weather)(weather['weather'], weather['weather_note'])


          I use a dictionary object named weather_indicators to store the patterns. You can add more patterns to it. If the amount of patterns is very large (like hundreds), then perhaps consider storing them in some other object like a database table or csv file or something and then reading that into the code. You'll obviously have to rework the above code at that point, since that's out of scope of your question.



          But basically I create a function that looks for a certain indicator word (e.g. "rain") and if the word is in the weather_note value then I set the weather column to be the specified value from the weather_indicator dictionary object. Then apply the function to the weather column of the data frame using numpy's vectorize function.






          share|improve this answer

























          • This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

            – Megan
            Mar 27 at 10:48













          1












          1








          1







          Here's how I'd do it. I used numpy in this code... hope that's okay. I just like numpy's vectorize method a lot. Pandas has an equivalent, but I don't tend to use it. The vectorize method (seen in last line of the code) is made for situations like this where you want to do *something* to a whole column, but it does it without requiring you to specify a loop in your code (it does the loop behind-the-scenes for you).



          import pandas as pd
          import numpy as np

          weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
          weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])

          weather_indicators = 'rain': 'rainy',
          'drizzle': 'rainy',
          'sun': 'sunny',
          'bright': 'sunny',
          # add each pattern to this dictionary


          def determine_weather(weather, weather_note):
          output = weather
          if weather == 'unknown':
          for indicator in weather_indicators:
          if indicator in weather_note:
          output = weather_indicators[indicator]
          return output


          weather['weather'] = np.vectorize(determine_weather)(weather['weather'], weather['weather_note'])


          I use a dictionary object named weather_indicators to store the patterns. You can add more patterns to it. If the amount of patterns is very large (like hundreds), then perhaps consider storing them in some other object like a database table or csv file or something and then reading that into the code. You'll obviously have to rework the above code at that point, since that's out of scope of your question.



          But basically I create a function that looks for a certain indicator word (e.g. "rain") and if the word is in the weather_note value then I set the weather column to be the specified value from the weather_indicator dictionary object. Then apply the function to the weather column of the data frame using numpy's vectorize function.






          share|improve this answer















          Here's how I'd do it. I used numpy in this code... hope that's okay. I just like numpy's vectorize method a lot. Pandas has an equivalent, but I don't tend to use it. The vectorize method (seen in last line of the code) is made for situations like this where you want to do *something* to a whole column, but it does it without requiring you to specify a loop in your code (it does the loop behind-the-scenes for you).



          import pandas as pd
          import numpy as np

          weather_data = [["unknown", "rainy"], ["unknown", "sun"], ["rainy", "not sunny at all"], ["stormy", "a lot of rain"]]
          weather = pd.DataFrame(weather_data, columns = ["weather", "weather_note"])

          weather_indicators = 'rain': 'rainy',
          'drizzle': 'rainy',
          'sun': 'sunny',
          'bright': 'sunny',
          # add each pattern to this dictionary


          def determine_weather(weather, weather_note):
          output = weather
          if weather == 'unknown':
          for indicator in weather_indicators:
          if indicator in weather_note:
          output = weather_indicators[indicator]
          return output


          weather['weather'] = np.vectorize(determine_weather)(weather['weather'], weather['weather_note'])


          I use a dictionary object named weather_indicators to store the patterns. You can add more patterns to it. If the amount of patterns is very large (like hundreds), then perhaps consider storing them in some other object like a database table or csv file or something and then reading that into the code. You'll obviously have to rework the above code at that point, since that's out of scope of your question.



          But basically I create a function that looks for a certain indicator word (e.g. "rain") and if the word is in the weather_note value then I set the weather column to be the specified value from the weather_indicator dictionary object. Then apply the function to the weather column of the data frame using numpy's vectorize function.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 18:31

























          answered Mar 26 at 18:25









          LetEpsilonBeLessThanZeroLetEpsilonBeLessThanZero

          1,0045 silver badges15 bronze badges




          1,0045 silver badges15 bronze badges












          • This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

            – Megan
            Mar 27 at 10:48

















          • This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

            – Megan
            Mar 27 at 10:48
















          This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

          – Megan
          Mar 27 at 10:48





          This worked well! Thanks so much. Some extra details for anybody looking, based on adapting for my actual data: 1) In the dictionary, you can have multiple keys in one line, for e.g. 'rain|drizzle': 'rainy', which avoids lots of repetition if you have lots of values. 2) Make sure you don't have NAs in the column you are getting the info from (weather_note in this example) or it will throw errors at you.

          – Megan
          Mar 27 at 10:48













          0














          Assign value from weather_note if value in weather is 'unknown'. Replace words like sun with sunny using df.replace.



          weather.loc[weather['weather'] == 'unknown', 'weather'] = weather['weather_note']
          weather['weather'].replace('sun', 'sunny', inplace = True)

          weather weather_note
          0 rainy rainy
          1 sunny sun
          2 rainy not sunny at all
          3 stormy a lot of rain





          share|improve this answer























          • Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

            – Megan
            Mar 27 at 10:51















          0














          Assign value from weather_note if value in weather is 'unknown'. Replace words like sun with sunny using df.replace.



          weather.loc[weather['weather'] == 'unknown', 'weather'] = weather['weather_note']
          weather['weather'].replace('sun', 'sunny', inplace = True)

          weather weather_note
          0 rainy rainy
          1 sunny sun
          2 rainy not sunny at all
          3 stormy a lot of rain





          share|improve this answer























          • Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

            – Megan
            Mar 27 at 10:51













          0












          0








          0







          Assign value from weather_note if value in weather is 'unknown'. Replace words like sun with sunny using df.replace.



          weather.loc[weather['weather'] == 'unknown', 'weather'] = weather['weather_note']
          weather['weather'].replace('sun', 'sunny', inplace = True)

          weather weather_note
          0 rainy rainy
          1 sunny sun
          2 rainy not sunny at all
          3 stormy a lot of rain





          share|improve this answer













          Assign value from weather_note if value in weather is 'unknown'. Replace words like sun with sunny using df.replace.



          weather.loc[weather['weather'] == 'unknown', 'weather'] = weather['weather_note']
          weather['weather'].replace('sun', 'sunny', inplace = True)

          weather weather_note
          0 rainy rainy
          1 sunny sun
          2 rainy not sunny at all
          3 stormy a lot of rain






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 18:34









          VaishaliVaishali

          24.3k4 gold badges16 silver badges39 bronze badges




          24.3k4 gold badges16 silver badges39 bronze badges












          • Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

            – Megan
            Mar 27 at 10:51

















          • Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

            – Megan
            Mar 27 at 10:51
















          Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

          – Megan
          Mar 27 at 10:51





          Thanks for your answer. This didn't work for my purpose because I think it is duplicating weather_note and then changing the sun value retroactively rather than assigning to a certain value in weather based on weather_note. So it works for this toy data but not my longer data where there are lots more potential combinations!

          – Megan
          Mar 27 at 10:51

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363096%2fchange-column-values-conditionally-and-repeat-several-times%23new-answer', 'question_page');

          );

          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







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해